Skip to content
Snippets Groups Projects

Upload records to the OSSR on notebook and improve __repr__ on Records class

Merged Enrique Garcia requested to merge update_ossr_api_notebook into master
1 unresolved thread

improve repr on Records class will dump a formatted json string instead of all the answer.

Merge request reports

Pipeline #137839 passed

Pipeline passed for 29dd8257 on update_ossr_api_notebook

Test coverage 76.00% (0.00%) from 1 job
Test summary results are being parsed

Merged by Enrique GarciaEnrique Garcia 3 years ago (Sep 28, 2021 8:48am UTC)

Loading

Pipeline #137840 passed

Pipeline passed for f0b02cc8 on master

Test coverage 76.00% (0.00%) from 1 job

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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?

  • Where are you running the Notebook ? I get this (in my local Notebook, not in the one rendered by the MR). Screenshot_2021-09-27_at_17.42.49

  • I don't get that at all in a local notebook

  • I think it's my ipython display that is broken

  • Please register or sign in to reply
  • 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__ to Record(self.id), provide a .peek() method equivalent to the current print_info and have a print_data method to print the whole data (as current __repr__)?

    Second point can be addressed in a different PR though.

  • Note: not even sure the print_data would be necessary...

  • Completely agree with separating the notebooks, indeed.

  • Enrique Garcia added 1 commit

    added 1 commit

    • 29dd8257 - Separate notebooks into two. Update internal links and re-run notebooks

    Compare with previous version

  • Notebooks updated. Second point will be done in another PR

  • Enrique Garcia approved this merge request

    approved this merge request

  • Enrique Garcia mentioned in commit f0b02cc8

    mentioned in commit f0b02cc8

  • Please register or sign in to reply
    Loading