-
Notifications
You must be signed in to change notification settings - Fork 68
[Refactor] Clarify a few csv_importer
types and names
#949
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
Conversation
ProblemCI is failing. I can repro on my local machine by running the same command CI runs
wherein it complains about the relative imports I use
But I didn't run into this issue locally when running the same command with a volume mount
How does the volume mount remove this issue? 🤔 AnswerUPDATE: so it appears that we're adding a new source directory with the volume mount that is usually not present.
So in the CI version, the Future WorkCan we just add that directory to our Docker image instructions? Looking at the CI file, we can see that the setup.sh script here actually moves the I'm going to leave this alone for now. There are many ways to "fix" our directory issues there and I'm not ready to do an exhaustive review of all our options for fixing that at this point (maybe relative imports, maybe directory restructuring, maybe renaming ResolutionSo I'm just going to let this go, focus on the JIT meta computation priority, and revert all the relative directory imports. |
b5384d7
to
7c111f5
Compare
csv_importer
types and names
* rename RowValues to CsvRowValue * make CsvRowValue into a dataclass * remove argument in load_csv only used for test mocks; correctly mock test * update tests
9f60604
to
87220a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gorgeous change, I'll accept the long line lengths as a necessary evil if I must
@@ -37,6 +49,7 @@ class CsvImporter: | |||
MIN_YEAR = 2019 | |||
MAX_YEAR = 2030 | |||
|
|||
# The datatypes expected by pandas.read_csv. Int64 is like float in that it can handle both numbers and nans. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏆
missing_value, missing_stderr, missing_sample_size | ||
) | ||
return (row_values, None) | ||
return (CsvRowValue(geo_id, value, stderr, sample_size, missing_value, missing_stderr, missing_sample_size), None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this harder to read but I will hold my nose and accept it as the way of the future
@@ -6,8 +6,7 @@ | |||
import unittest | |||
from unittest.mock import MagicMock | |||
|
|||
from delphi.epidata.acquisition.covidcast.csv_to_database import get_argument_parser, main, \ | |||
collect_files, upload_archive, make_handlers | |||
from delphi.epidata.acquisition.covidcast.csv_to_database import get_argument_parser, main, collect_files, upload_archive, make_handlers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh same, I don't like it but it's fine
I guess I have to admit it... I'm a long-line lover. There are dozens of us. Dozens! |
A few small refactors for clarity that I couldn't help myself in making while working on #947.
Most of the changes are purely for better readability. No functionality is altered, except for the interface of
load_csv
, but this should not affect actual usage.Changes:
pandas
optional argument fromload_csv
that was only used for test mocksunittest.patch
to mock test insteadcsv_to_database
with a few relative importsFurther details:
I changed
where
pandas
was just an abstract argument to the Pandas library meant for mocking. Instead of complicating this function's interface, we can just use@patch("pandas.read_csv")
in the tests, which automatically mocks any calls to that function with our desired mock object.Prerequisites:
dev
branchdev