Skip to content

Commit

Permalink
chore: Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
anth-volk committed Sep 6, 2024
1 parent de5da1d commit 20873ab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
12 changes: 9 additions & 3 deletions docs/pages/Benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
21 changes: 14 additions & 7 deletions policyengine_us_data/utils/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 20873ab

Please sign in to comment.