Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13 Spreadsheet download #22

Merged
merged 53 commits into from
Jul 21, 2021
Merged

#13 Spreadsheet download #22

merged 53 commits into from
Jul 21, 2021

Conversation

ke4
Copy link
Contributor

@ke4 ke4 commented Jul 12, 2021

closes ebi-ait/dcp-ingest-central#13

Changes:

  • Convert submission payload to flat JSON
  • Convert flat JSON to XLSX

@ke4 ke4 requested a review from a team July 12, 2021 16:32
ingest/downloader/downloader.py Outdated Show resolved Hide resolved
ingest/downloader/downloader.py Outdated Show resolved Hide resolved
tests/unit/downloader/test_downloader.py Outdated Show resolved Hide resolved
tests/unit/downloader/test_xls_generation.py Outdated Show resolved Hide resolved
@ke4 ke4 requested a review from amnonkhen July 12, 2021 20:51
self._flatten_object(value, flattened_object, parent_key=full_key)
else:
flattened_object[full_key] = str(value)
elif isinstance(object, list):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be an else path as well that raises an exception to protect client from unsupported use?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for that, if you check where this function is being called, it can only be called if it's a dict or list.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be called by someone else using different arguments?

ingest/downloader/flattener.py Outdated Show resolved Hide resolved
ingest/downloader/downloader.py Outdated Show resolved Hide resolved
ingest/downloader/downloader.py Outdated Show resolved Hide resolved
elif isinstance(object, list):
self._flatten_list(flattened_object, object, parent_key)

def _flatten_list(self, flattened_object, object, parent_key):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are some of these methods returning values and some modifying properties on the object without returning it? In general, I think it's bad practice for a function to modify an object since it can cause unexpected side effects. I think it would be better to copy the object, change it, and return it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are private functions so it shouldn't be a big concern. They are needed to be modified because it's part of the recursive logic. I'm not yet sure how to achieve it with your suggestion to copy the object, change it, and return it. I will think about it. Could we leave that for later?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah no problem. I was just curious more than anything. Being private makes sense

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @jacobwindsor that pure functions are an ideal to aspire to, since side0effects can be a source of surprise and therefore bugs. Sometimes, if we make an explicit decision to have side-effects, the function's name should make it clear.

tests/unit/downloader/test_xls_generation.py Show resolved Hide resolved
Copy link
Contributor

@amnonkhen amnonkhen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some clean code comments

Copy link
Contributor

@amnonkhen amnonkhen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments

Copy link
Contributor

@amnonkhen amnonkhen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

almost there


def __add_row_content(self, worksheet, headers: list, values: dict):
@staticmethod
def __add_row_content(worksheet, headers: list, row_no: int, values: dict):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can can call it row_number, or if you want to shorten, rownum.

Copy link
Contributor

@amnonkhen amnonkhen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a small fix remaining

@ke4 ke4 merged commit 4160ec8 into master Jul 21, 2021
@MightyAx MightyAx deleted the 13_spreadsheet-download branch July 6, 2022 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Downloadable spreadsheet to stay up to date with any metadata updates that are made
5 participants