Skip to content

Commit

Permalink
finalize payload and response for sources, schema and metadata upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Alig1493 committed Apr 24, 2024
1 parent 77e2c0d commit e550231
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/pycrunch/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ class ElementResponseHandler(lemonpy.ResponseHandler):
parsers = {"application/json": parse_json_element_from_response}

def status_401(self, r):
print(r.json())
login_url = r.json()["urls"]["login_url"]
if r.request.url == login_url:
# This means that the requests was made on the login_url, so it was
Expand Down
16 changes: 9 additions & 7 deletions src/pycrunch/importing.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,17 @@ def add_schema_metadata(self, ds, source_url, filename, fp, mimetype, schema, me
data={
"schema": schema,
"metadata": metadata,
"crunchlake": "create",
"dataset_id": ds.get("self", "").split("/")[-2]
}
)

return shoji.Entity(ds.session, body={
"status_code": response.status_code,
"payload": response.payload,
"source_url": response.headers.get("Location")
}
)
return response

def debug_source_payload(self, ds, source_url):
r = ds.session.get(source_url)
if r.payload is None:
raise TypeError("Response could not be parsed.", r)
return r.payload

def add_source(self, ds, filename, fp, mimetype):
"""Create a new Source on the given dataset and return its URL."""
Expand Down

0 comments on commit e550231

Please sign in to comment.