diff --git a/src/pycrunch/elements.py b/src/pycrunch/elements.py index c4a3053..cb8d61e 100644 --- a/src/pycrunch/elements.py +++ b/src/pycrunch/elements.py @@ -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 diff --git a/src/pycrunch/importing.py b/src/pycrunch/importing.py index 2d4a647..4cbb5d1 100644 --- a/src/pycrunch/importing.py +++ b/src/pycrunch/importing.py @@ -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."""