This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_pr_label(owner: str, repo: str, token: str, pull_number: str) -> None: | |
url = "https://api.github.com/repos/{}/{}/issues/{}/labels".format(owner, repo, pull_number) | |
headers = { | |
"Authorization": "token {}".format(token), | |
"Content-Type": "application/json" | |
} | |
payload = { | |
"labels" : ["driver"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def request_pr_reviwer(owner: str, repo: str, token: str, pull_number: str, reviewers: list) -> None: | |
url = "https://api.github.com/repos/{}/{}/pulls/{}/requested_reviewers".format(owner, repo, pull_number) | |
headers = { | |
"Authorization": "token {}".format(token), | |
"Content-Type": "application/json" | |
} | |
payload = { | |
"reviewers" : reviewers | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_pull_request(owner: str, repo: str, token: str, branch_name: str, new_branch: str, base: str) -> str: | |
"""Create a PR for the new branch, return the PR number""" | |
url = "https://api.github.com/repos/{}/{}/pulls".format(owner, repo) | |
headers = { | |
"Authorization": "token {}".format(token), | |
"Content-Type": "application/json" | |
} | |
payload = { | |
"head": new_branch, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_file_contents(owner: str, repo: str, token: str, new_branch: str, sha: str, path: str) -> None: | |
"""Update the file content and add a commit""" | |
url = "https://api.github.com/repos/{}/{}/contents/{}".format(owner, repo, path) | |
headers = { | |
"Authorization": "token {}".format(token), | |
"Content-Type": "application/json" | |
} | |
with open(os.path.join(os.path.dirname(__file__), "../..", path),'rb') as content: | |
b64_content = base64.b64encode(content.read()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_file_sha(owner: str, repo: str, token: str, path: str) -> str: | |
"""Return the file's SHA for updating the file""" | |
url = "https://api.github.com/repos/{}/{}/contents/{}".format(owner, repo, path) | |
headers = { | |
"Authorization": "token {}".format(token), | |
"Content-Type": "application/json" | |
} | |
try: | |
response = requests.get(url, headers=headers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
import logging | |
import requests | |
import json | |
import datetime | |
import base64 | |
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_branch(owner: str, repo: str, token: str, base: str, new_branch: str) -> None: | |
"""Create a new branch""" | |
url = "https://api.github.com/repos/{}/{}/git/refs".format(owner, repo) | |
headers = { | |
"Authorization": "token {}".format(token), | |
"Content-Type": "application/json" | |
} | |
try: | |
get_response = requests.get(url+"/heads/"+base, headers=headers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sf_merged.loc[sf_merged['Cluster Labels'] == 4, sf_merged.columns[[1] + list(range(5, sf_merged.shape[1]))]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sf_merged.loc[sf_merged['Cluster Labels'] == 3, sf_merged.columns[[1] + list(range(5, sf_merged.shape[1]))]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sf_merged.loc[sf_merged['Cluster Labels'] == 2, sf_merged.columns[[1] + list(range(5, sf_merged.shape[1]))]] |
NewerOlder