Skip to content

Commit

Permalink
reduce line length to 100 (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
b9r5 authored Dec 21, 2024
1 parent 05363e7 commit a184650
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
line-length = 110 # ideally I want this to be less than 100 but don't wanna test and change the sql stuff
line-length = 100 # ideally I want this to be less than 100 but don't wanna test and change files with longer lines
target-version = "py310"
lint.select = [
"E", # pycodestyle errors
Expand Down
3 changes: 2 additions & 1 deletion src/discord-cluster-manager/cogs/github_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ async def check_workflow_status(self, run_id, thread):
return run.conclusion, logs, run.html_url

await thread.send(
f"Workflow: {run.status} running for {elapsed_time.total_seconds():.2f} seconds\n"
f"Workflow: {run.status} running for "
f"{elapsed_time.total_seconds():.2f} seconds\n"
f"Live view: <{run.html_url}>"
)
await asyncio.sleep(60)
Expand Down
3 changes: 2 additions & 1 deletion src/discord-cluster-manager/cogs/leaderboard_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ async def leaderboard_create(
if "duplicate key" in err:
await send_discord_message(
interaction,
f'Error: Tried to create a leaderboard "{leaderboard_name}" that already exists.',
'Error: Tried to create a leaderboard '
f'"{leaderboard_name}" that already exists.',
ephemeral=True,
)
else:
Expand Down
6 changes: 4 additions & 2 deletions src/discord-cluster-manager/cogs/modal_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ async def run_modal(
await thread.send(f"**Processing `{script.filename}` with {gpu_type.name}...**")

script_content = (await script.read()).decode("utf-8")
status_msg = await thread.send("**Running on Modal...**\n> ⏳ Waiting for available GPU...")
status_msg = await thread.send(
"**Running on Modal...**\n> ⏳ Waiting for available GPU...")

result, execution_time_ms = await self.trigger_modal_run(script_content, script.filename)
result, execution_time_ms = await self.trigger_modal_run(
script_content, script.filename)

# Update status message to show completion
await status_msg.edit(content="**Running on Modal...**\n> ✅ Job completed!")
Expand Down
17 changes: 9 additions & 8 deletions src/discord-cluster-manager/cogs/verify_run_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ async def verify_github_run(
)

if all_patterns_found:
send_discord_message(
await send_discord_message(
interaction,
f"✅ GitHub run ({choice.name}) completed successfully - all expected messages found!",
f"✅ GitHub run ({choice.name}) completed successfully - "
"all expected messages found!",
)
return True
else:
Expand All @@ -86,7 +87,7 @@ async def verify_github_run(
for content in message_contents
)
]
send_discord_message(
await send_discord_message(
interaction,
f"❌ GitHub run ({choice.name}) verification failed. Missing expected messages:\n"
+ "\n".join(f"- {pattern}" for pattern in missing_patterns),
Expand Down Expand Up @@ -122,7 +123,7 @@ async def verify_modal_run(
)

if all_patterns_found:
send_discord_message(
await send_discord_message(
interaction,
"✅ Modal run completed successfully - all expected messages found!",
)
Expand All @@ -136,7 +137,7 @@ async def verify_modal_run(
for content in message_contents
)
]
send_discord_message(
await send_discord_message(
interaction,
"❌ Modal run verification failed. Missing expected messages:\n"
+ "\n".join(f"- {pattern}" for pattern in missing_patterns),
Expand Down Expand Up @@ -168,15 +169,15 @@ async def verify_runs(self, interaction: discord.Interaction):
)

if all(results):
send_discord_message(interaction, "✅ All runs completed successfully!")
await send_discord_message(interaction, "✅ All runs completed successfully!")
else:
send_discord_message(
await send_discord_message(
interaction,
"❌ Some runs failed! Consult messages above for details.",
)

except Exception as e:
logger.error(f"Error starting verification runs: {e}", exc_info=True)
send_discord_message(
await send_discord_message(
interaction, f"❌ Problem performing verification runs: {str(e)}"
)
24 changes: 19 additions & 5 deletions src/discord-cluster-manager/leaderboard_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

class LeaderboardDB:
def __init__(
self, host: str, database: str, user: str, password: str, port: str = "5432"
self,
host: str,
database: str,
user: str,
password: str,
port: str = "5432"
):
"""Initialize database connection parameters"""
self.connection_params = {
Expand Down Expand Up @@ -58,7 +63,10 @@ def __exit__(self, exc_type, exc_val, exc_tb):
"""Context manager exit"""
self.disconnect()

def create_leaderboard(self, leaderboard: LeaderboardItem) -> Optional[None]:
def create_leaderboard(
self,
leaderboard: LeaderboardItem
) -> Optional[None]:
try:
self.cursor.execute(
"""
Expand All @@ -81,8 +89,10 @@ def create_submission(self, submission: SubmissionItem):
try:
self.cursor.execute(
"""
INSERT INTO leaderboard.submission (problem_id, name, user_id, code, submission_time, score)
VALUES ((SELECT id FROM leaderboard.problem WHERE name = %s), %s, %s, %s, %s, %s)
INSERT INTO leaderboard.submission (problem_id, name, user_id,
code, submission_time, score)
VALUES ((SELECT id FROM leaderboard.problem WHERE name = %s),
%s, %s, %s, %s, %s)
""",
(
submission["leaderboard_name"],
Expand Down Expand Up @@ -110,7 +120,11 @@ def get_leaderboards(self) -> list[LeaderboardItem]:

def get_leaderboard(self, leaderboard_name: str) -> int | None:
self.cursor.execute(
"SELECT id, name, deadline, reference_code FROM leaderboard.problem WHERE name = %s",
"""
SELECT id, name, deadline, reference_code
FROM leaderboard.problem
WHERE name = %s
""",
(leaderboard_name,),
)

Expand Down

0 comments on commit a184650

Please sign in to comment.