Skip to content

Commit

Permalink
Fix Zenodo export
Browse files Browse the repository at this point in the history
  • Loading branch information
webb-ben committed Mar 3, 2025
1 parent 58db0a0 commit cafa06a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/lib_test/classes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ def test_s3_read_stream():
stream = S3().read_stream("streamKey")
assert stream is not None
data = b""
for chunk in stream.stream(amt=1024 * 1024):
for chunk in stream:
data += chunk
assert data == longData
6 changes: 3 additions & 3 deletions userCode/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ def nquads_to_zenodo(
get_dagster_logger().info(f"Deposit created with ID: {deposit_id}")

# Use the deposit ID to upload the file
response = requests.post(
f"{ZENODO_API_URL}/{deposit_id}/files",
files={"file": ("nquads.nt", stream)},
response = requests.put(
deposit["links"]["bucket"] + "/" + "nquads.nt",
data=stream,
headers={"Authorization": f"Bearer {TOKEN}"},
)

Expand Down
7 changes: 6 additions & 1 deletion userCode/lib/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ def read_stream(self, remote_path: str):
response: BaseHTTPResponse = self.client.get_object(
GLEANER_MINIO_BUCKET, remote_path
)
return response # Return the stream directly
try:
for chunk in response.stream(8 * 1024 * 1024):
yield chunk
finally:
response.close()
response.release_conn()


class RcloneClient:
Expand Down

0 comments on commit cafa06a

Please sign in to comment.