Upload records to the OSSR on notebook and improve __repr__ on Records class
improve repr on Records class will dump a formatted json string instead of all the answer.
Merge request reports
Activity
433 432 return f"Record #{self.id} : {self.title}" 434 433 435 434 def __repr__(self): 436 return f"Record({self.data})" 435 return json.dumps(self.data, indent=4, sort_keys=True) Testing this in a notebook, I don't see a real improvement. Instead of
{"conceptdoi": "10.5281/zenodo.5524912", "conceptrecid": "5524912", "created": "2021-09-23T15:03:51.644210+00:00", "doi": "10.5281/zenodo.5524913", "files": [{"bucket": "165e5f9a-17bc-4792-bd04-b01cef8b9fc7", "checksum": "md5:20d7ce7abc06541bed2655f19edfb956", "key": "codemeta.json", "links": {"self": "https://zenodo.org/api/files/165e5f9a-17bc-4792-bd04-b01cef8b9fc7/codemeta.json"}, "size": 3271, "type": "json"}, ...
If get
'{\n "conceptdoi": "10.5281/zenodo.5524912",\n "conceptrecid": "5524912",\n "created": "2021-09-23T15:03:51.644210+00:00",\n "doi": "10.5281/zenodo.5524913",\n "files": [\n {\n "bucket": "165e5f9a-17bc-4792-bd04-b01cef8b9fc7",\n "checksum": "md5:20d7ce7abc06541bed2655f19edfb956",\n "key": "codemeta.json",\n "links": {\n "self": "https://zenodo.org/api/files/165e5f9a-17bc-4792-bd04-b01cef8b9fc7/codemeta.json"\n },\n "size": 3271,\n "type": "json"\n },\n ...
The line breaks are now displayed and I don't feel like this is more readable.
Is this a config problem?
Two general comments:
-
it might be worth splitting the notebook in two:
- "explore the OSSR"
- "upload record to the OSSR"
-
I was actually thinking today that this representation, however exhaustive and what is the most conform to Python convention is actually really annoying and that informative this it is not really readable. What do you think about changing the
__repr__
toRecord(self.id)
, provide a.peek()
method equivalent to the currentprint_info
and have aprint_data
method to print the whole data (as current__repr__
)?
Second point can be addressed in a different PR though.
-
added 1 commit
- 29dd8257 - Separate notebooks into two. Update internal links and re-run notebooks
mentioned in commit f0b02cc8