Skip to content

Commit

Permalink
ruff: 2025 format
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten committed Feb 3, 2025
1 parent 8ada2d3 commit b2765b1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions ampel/ztf/archive/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def post_alert_chunk(
alerts, schema = content_and_schema

blob, ranges = pack_records(alerts, schema)
key = f'{hashlib.sha256(json.dumps(sorted(alert["candid"] for alert in alerts)).encode("utf-8")).hexdigest()}.avro'
key = f"{hashlib.sha256(json.dumps(sorted(alert['candid'] for alert in alerts)).encode('utf-8')).hexdigest()}.avro"
md5 = base64.b64encode(hashlib.md5(blob).digest()).decode("utf-8")

obj = bucket.Object(key)
Expand Down Expand Up @@ -766,7 +766,9 @@ def create_stream_from_query(
) from None

conn.execute(
sqlalchemy.text(f"set statement_timeout={settings.stream_query_timeout*1000};")
sqlalchemy.text(
f"set statement_timeout={settings.stream_query_timeout * 1000};"
)
)
group_id = archive._create_read_queue(conn, name, query.chunk_size) # noqa: SLF001
conn.commit()
Expand Down
2 changes: 1 addition & 1 deletion migrations/01_update_hpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@
],
)
dt = time.time() - t0
log.info(f"updated {len(rows)/dt:.1f} rows/s")
log.info(f"updated {len(rows) / dt:.1f} rows/s")
2 changes: 1 addition & 1 deletion tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def archive(integration):
"ARCHIVE_WRITE_USER=ampel-client",
"-P",
"-v",
f"{Path(__file__).parent/'test-data'/'initdb'/'archive'}:/docker-entrypoint-initdb.d",
f"{Path(__file__).parent / 'test-data' / 'initdb' / 'archive'}:/docker-entrypoint-initdb.d",
POSTGRES_IMAGE,
],
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_archivedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,4 +665,4 @@ def test_seekable_avro(alert_generator, cutouts: bool):
assert reco == alert
break
else:
raise ValueError(f'{alert["candid"]} not found')
raise ValueError(f"{alert['candid']} not found")
12 changes: 6 additions & 6 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ async def test_programid_auth(
assert response.status_code == status.HTTP_200_OK
assert mock_db.get_alerts_for_object.call_args.kwargs[
"programid"
] == params.get(
"programid"
), "programid is passed through for partnership token"
] == params.get("programid"), (
"programid is passed through for partnership token"
)
else:
assert response.status_code == status_code
if response.status_code == status.HTTP_200_OK:
assert (
mock_db.get_alerts_for_object.call_args.kwargs["programid"] == 1
), "non-partnership tokens always query programid 1"
assert mock_db.get_alerts_for_object.call_args.kwargs["programid"] == 1, (
"non-partnership tokens always query programid 1"
)


@pytest.mark.asyncio
Expand Down

0 comments on commit b2765b1

Please sign in to comment.