diff --git a/CHANGELOG.md b/CHANGELOG.md index 71dc79a79b..f0776db3db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # nf-core/tools: Changelog +## [v2.4.1 - Cobolt Koala Patch](https://github.com/nf-core/tools/releases/tag/2.4) - [2022-05-16] + +- Patch release to try to fix the template sync ([#1585](https://github.com/nf-core/tools/pull/1585)). + ## [v2.4 - Cobolt Koala](https://github.com/nf-core/tools/releases/tag/2.4) - [2022-05-16] ### Template diff --git a/nf_core/sync.py b/nf_core/sync.py index e9f5ff391c..7ce4f0fa67 100644 --- a/nf_core/sync.py +++ b/nf_core/sync.py @@ -76,11 +76,14 @@ def __init__( self.gh_repo = gh_repo self.pr_url = "" + # Set up the API auth if supplied on the command line self.gh_api = nf_core.utils.gh_api - if self.gh_username and "GITHUB_AUTH_TOKEN" in os.environ: - self.gh_api.auth = requests.auth.HTTPBasicAuth(self.gh_username, os.environ["GITHUB_AUTH_TOKEN"]) - self.gh_api.return_ok = [200, 201] self.gh_api.lazy_init() + if self.gh_username and "GITHUB_AUTH_TOKEN" in os.environ: + log.debug(f"Authenticating sync as {self.gh_username}") + self.gh_api.setup_github_auth( + requests.auth.HTTPBasicAuth(self.gh_username, os.environ["GITHUB_AUTH_TOKEN"]) + ) def sync(self): """Find workflow attributes, create a new template pipeline on TEMPLATE""" @@ -320,7 +323,6 @@ def make_pull_request(self): # Make new pull-request stderr = rich.console.Console(stderr=True, force_terminal=nf_core.utils.rich_force_colors()) - log.debug("Submitting PR to GitHub API") with self.gh_api.cache_disabled(): try: r = self.gh_api.request_retry( diff --git a/nf_core/utils.py b/nf_core/utils.py index d56d43ca64..4cb64e6b0a 100644 --- a/nf_core/utils.py +++ b/nf_core/utils.py @@ -454,7 +454,7 @@ def __call__(self, r): log.debug(f"Using GitHub auth: {self.auth_mode}") - def log_content_headers(self, request): + def log_content_headers(self, request, post_data=None): """ Try to dump everything to the console, useful when things go wrong. """ @@ -462,13 +462,17 @@ def log_content_headers(self, request): log.debug(f"From requests cache: {request.from_cache}") log.debug(f"Request status code: {request.status_code}") log.debug(f"Request reason: {request.reason}") + if post_data is None: + post_data = {} try: log.debug(json.dumps(dict(request.headers), indent=4)) log.debug(json.dumps(request.json(), indent=4)) + log.debug(json.dumps(post_data, indent=4)) except Exception as e: log.debug(f"Could not parse JSON response from GitHub API! {e}") log.debug(request.headers) log.debug(request.content) + log.debug(post_data) def safe_get(self, url): """ @@ -504,14 +508,16 @@ def request_retry(self, url, post_data=None): while True: # GET request if post_data is None: + log.debug(f"Seding GET request to {url}") r = self.get(url=url) # POST request else: + log.debug(f"Seding POST request to {url}") r = self.post(url=url, json=post_data) # Failed but expected - try again if r.status_code in self.return_retry: - self.log_content_headers(r) + self.log_content_headers(r, post_data) log.debug(f"GitHub API PR failed - got return code {r.status_code}") wait_time = float(re.sub("[^0-9]", "", str(r.headers.get("Retry-After", 0)))) if wait_time == 0: @@ -522,8 +528,8 @@ def request_retry(self, url, post_data=None): # Unexpected error - raise elif r.status_code not in self.return_ok: - self.log_content_headers(r) - raise AssertionError(f"GitHub API PR failed - got return code {r.status_code} from {url}") + self.log_content_headers(r, post_data) + raise RuntimeError(f"GitHub API PR failed - got return code {r.status_code} from {url}") # Success! else: diff --git a/setup.py b/setup.py index 2622db133b..1f86df70aa 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages -version = "2.4" +version = "2.4.1" with open("README.md") as f: readme = f.read()