From 20873abc621b135df1b739f81a5033e667d025b1 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Fri, 6 Sep 2024 21:32:04 +0200 Subject: [PATCH] chore: Lint --- docs/pages/Benchmarks.py | 12 +++++++++--- policyengine_us_data/utils/github.py | 21 ++++++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/pages/Benchmarks.py b/docs/pages/Benchmarks.py index c7df765..b23cf0b 100644 --- a/docs/pages/Benchmarks.py +++ b/docs/pages/Benchmarks.py @@ -99,9 +99,15 @@ def compare_datasets(): "The table below shows the relative error for each target in each dataset, and the change after moving the ECPS." ) -long_to_wide = df.pivot(index="Target", columns="Dataset", values="Abs. Error %").reset_index() -long_to_wide["CPS to ECPS change"] = long_to_wide["Enhanced CPS 2024"] - long_to_wide["CPS 2024 (2022-based)"] -long_to_wide["PUF to ECPS change"] = long_to_wide["Enhanced CPS 2024"] - long_to_wide["PUF 2024 (2022-based)"] +long_to_wide = df.pivot( + index="Target", columns="Dataset", values="Abs. Error %" +).reset_index() +long_to_wide["CPS to ECPS change"] = ( + long_to_wide["Enhanced CPS 2024"] - long_to_wide["CPS 2024 (2022-based)"] +) +long_to_wide["PUF to ECPS change"] = ( + long_to_wide["Enhanced CPS 2024"] - long_to_wide["PUF 2024 (2022-based)"] +) long_to_wide.sort_values("cps_to_ecps_change", ascending=False) st.dataframe(long_to_wide, use_container_width=True) diff --git a/policyengine_us_data/utils/github.py b/policyengine_us_data/utils/github.py index 6a46543..c4f2401 100644 --- a/policyengine_us_data/utils/github.py +++ b/policyengine_us_data/utils/github.py @@ -64,10 +64,13 @@ def download( def create_session_with_retries(): session = requests.Session() - retries = Retry(total=5, backoff_factor=1, status_forcelist=[502, 503, 504]) - session.mount('https://', HTTPAdapter(max_retries=retries)) + retries = Retry( + total=5, backoff_factor=1, status_forcelist=[502, 503, 504] + ) + session.mount("https://", HTTPAdapter(max_retries=retries)) return session + def upload( org: str, repo: str, release_tag: str, file_name: str, file_path: str ) -> bytes: @@ -98,19 +101,23 @@ def upload( len(r.content) ) ), - timeout=300 # 5 minutes timeout + timeout=300, # 5 minutes timeout ) if response.status_code == 201: return response.json() else: - print(f"Attempt {attempt + 1} failed with status code {response.status_code}. Response: {response.text}") - + print( + f"Attempt {attempt + 1} failed with status code {response.status_code}. Response: {response.text}" + ) + except requests.exceptions.RequestException as e: print(f"Attempt {attempt + 1} failed with error: {str(e)}") - + if attempt < max_retries - 1: - wait_time = (attempt + 1) * 60 # Wait 1 minute, then 2 minutes, then 3 minutes + wait_time = ( + attempt + 1 + ) * 60 # Wait 1 minute, then 2 minutes, then 3 minutes print(f"Waiting {wait_time} seconds before retrying...") time.sleep(wait_time)