-
Notifications
You must be signed in to change notification settings - Fork 0
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
Confirm drop by prefix, add --continue #140
Conversation
mock_cursor.__iter__.return_value = [[query_res]] | ||
parser = StudyManifestParser("./tests/test_data/study_valid/") | ||
tables = parser.clean_study(mock_cursor, schema, verbose, prefix=prefix) | ||
with mock.patch.object(builtins, "input", lambda _: confirm): |
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.
fun
cumulus_library/study_parser.py
Outdated
print(continue_from.replace(".sql", "")) | ||
print(file.replace(".sql", "")) | ||
if continue_from.replace(".sql", "") == file.replace(".sql", ""): | ||
sql_files = sql_files[sql_files.index(file) :] |
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.
nit: you could save yourself an index()
call by doing for i, file in enumerate(sql_files):
above, but 🤷
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.
ooh, i dig it
cumulus_library/study_parser.py
Outdated
if not match_found: | ||
sys.exit(f"No tables matching '{continue_from}' found") |
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.
You ready for this Python nonsense? Just do else:
and skip match_found
. For/else lets you run code if the for loop never broke.
i.e.:
for file in sql_files:
if continue_from.replace(".sql", "") == file.replace(".sql", ""):
sql_files = sql_files[sql_files.index(file) :]
break
else:
sys.exit(f"No tables matching '{continue_from}' found")
Alternatively, you could also do return sql_files[sql_files.index(file) :]
and unconditionally exit after the loop.
Or keep it! Whatever works for your sense of code cleanliness.
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.
taking the for\else
approach, just in case there's other post loop stuff that might end up here in the future.
cumulus_library/cli_parser.py
Outdated
build.add_argument( | ||
"--continue", | ||
dest="continue_from", | ||
help=(argparse.SUPPRESS), |
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.
Why the parens?
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.
copy pasted from elsewhere - why i did that in the first place, ¯\_(ツ)_/¯
This PR makes the following changes:
--prefix
argument Tech Debt: Add list of tables and confirmation to manual prefix dropping #129--continue
param for specifying a point in the manifest's list of SQL files to continue a build from (useful for debugging errors that occur at near the end of a build)Checklist
docs/
) needs to be updated