Skip to content

Commit 966dfac

Browse files
chore(launchpad): minor cleanup and config additions
1 parent 04f4c97 commit 966dfac

3 files changed

Lines changed: 29 additions & 27 deletions

File tree

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export LAUNCHPAD_ENV="development"
99
export LAUNCHPAD_HOST="0.0.0.0"
1010
export LAUNCHPAD_PORT="2218"
1111
export LAUNCHPAD_RPC_SHARED_SECRET="launchpad-also-very-long-value-haha"
12+
export SENTRY_BASE_URL="http://localhost:8000"
1213
# STATSD_HOST=... # defaults to 127.0.0.1
1314
# STATSD_PORT=... # defaults to 8125
1415

src/launchpad/kafka.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def create_kafka_consumer(
4343
consumer_config = {
4444
"bootstrap.servers": config["bootstrap_servers"],
4545
"group.id": config["group_id"],
46-
"auto.offset.reset": "latest",
46+
"auto.offset.reset": config["auto_offset_reset"],
4747
"enable.auto.commit": False,
4848
"enable.auto.offset.store": False,
4949
}
@@ -136,4 +136,5 @@ def get_kafka_config() -> Dict[str, Any]:
136136
"concurrency": int(os.getenv("KAFKA_CONCURRENCY", "4")),
137137
"max_pending_futures": int(os.getenv("KAFKA_MAX_PENDING_FUTURES", "100")),
138138
"healthcheck_file": os.getenv("KAFKA_HEALTHCHECK_FILE"),
139+
"auto_offset_reset": os.getenv("KAFKA_AUTO_OFFSET_RESET", "latest"), # latest = skip old messages
139140
}

src/launchpad/sentry_client.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,6 @@ def __init__(self, base_url: str) -> None:
2727
if not self.shared_secret:
2828
raise RuntimeError("LAUNCHPAD_RPC_SHARED_SECRET must be provided or set as environment variable")
2929

30-
def assemble_size_analysis(
31-
self,
32-
org: str | int,
33-
project: str | int,
34-
artifact_id: str | int,
35-
checksum: str,
36-
chunks: list[str],
37-
) -> Dict[str, Any]:
38-
"""Call the assemble size analysis endpoint."""
39-
# Validate hex strings
40-
if not re.match(r"^[a-fA-F0-9]+$", checksum):
41-
raise ValueError("Invalid checksum format")
42-
for chunk in chunks:
43-
if not re.match(r"^[a-fA-F0-9]+$", chunk):
44-
raise ValueError("Invalid chunk format")
45-
46-
data = {
47-
"checksum": checksum,
48-
"chunks": chunks,
49-
"assemble_type": "size_analysis",
50-
}
51-
52-
endpoint = f"/api/0/internal/{org}/{project}/files/preprodartifacts/{artifact_id}/assemble-generic/"
53-
return self._make_json_request("POST", endpoint, data, operation="Assemble request")
54-
5530
def download_artifact(self, org: str, project: str, artifact_id: str) -> Dict[str, Any]:
5631
"""Download preprod artifact."""
5732
endpoint = f"/api/0/internal/{org}/{project}/files/preprodartifacts/{artifact_id}/"
@@ -136,7 +111,7 @@ def upload_size_analysis_file(
136111
for attempt in range(max_retries):
137112
logger.debug(f"Assembly attempt {attempt + 1}/{max_retries}")
138113

139-
result = self.assemble_size_analysis(
114+
result = self._assemble_size_analysis(
140115
org=org,
141116
project=project,
142117
artifact_id=artifact_id,
@@ -285,6 +260,31 @@ def _upload_chunk(self, org: str, chunk: Dict[str, Any]) -> bool:
285260
logger.error(f"Chunk upload error: {e}")
286261
return False
287262

263+
def _assemble_size_analysis(
264+
self,
265+
org: str | int,
266+
project: str | int,
267+
artifact_id: str | int,
268+
checksum: str,
269+
chunks: list[str],
270+
) -> Dict[str, Any]:
271+
"""Call the assemble size analysis endpoint."""
272+
# Validate hex strings
273+
if not re.match(r"^[a-fA-F0-9]+$", checksum):
274+
raise ValueError("Invalid checksum format")
275+
for chunk in chunks:
276+
if not re.match(r"^[a-fA-F0-9]+$", chunk):
277+
raise ValueError("Invalid chunk format")
278+
279+
data = {
280+
"checksum": checksum,
281+
"chunks": chunks,
282+
"assemble_type": "size_analysis",
283+
}
284+
285+
endpoint = f"/api/0/internal/{org}/{project}/files/preprodartifacts/{artifact_id}/assemble-generic/"
286+
return self._make_json_request("POST", endpoint, data, operation="Assemble request")
287+
288288
def _create_multipart_body(self, boundary: str, filename: str, data: bytes) -> bytes:
289289
"""Create multipart/form-data body."""
290290
lines = [

0 commit comments

Comments
 (0)