Skip to content

Conversation

minhkhul
Copy link
Contributor

@minhkhul minhkhul commented Mar 9, 2023

This change helps acquisition switch to running per-indicator on Cronicle.

Add optional argument indicator_name to allow acquisition run on one specified indicator only. If this argument is not there, acquisition behavior does not change from current implementation, i.e. acquisition looks through all indicators inside data_dir for new csv files.

Additionally, to test the above addition accurately, this PR also replaces this magicmock test object with an argparse object in test_csv_uploading.

@minhkhul minhkhul changed the title add indicator_name Acquisition change for run in cronicle Mar 10, 2023
…l problem: This change allows the test to pass, but doesn't accurately test what happens when indicator_name is not included as argument when acquisition is run. Should probably use an actual argparse object for the args instead of a MagicMock to test next commit.
@minhkhul minhkhul requested a review from krivard March 13, 2023 19:01
@minhkhul minhkhul requested a review from korlaxxalrok March 15, 2023 18:51
korlaxxalrok
korlaxxalrok previously approved these changes Mar 21, 2023
Copy link
Contributor

@korlaxxalrok korlaxxalrok left a comment

Choose a reason for hiding this comment

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

Looks good! I will give my 👍 , but I think that @krivard and/or @melange396 should put eyes on it as well.

@korlaxxalrok korlaxxalrok requested a review from melange396 March 21, 2023 19:01
Copy link
Collaborator

@melange396 melange396 left a comment

Choose a reason for hiding this comment

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

nice job! just a couple little comments...

help="filename for log output (defaults to stdout)")
parser.add_argument(
'--indicator_name',
nargs='?',
Copy link
Collaborator

Choose a reason for hiding this comment

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

whats the purpose of this option? do we need it?

Copy link
Contributor Author

@minhkhul minhkhul Mar 21, 2023

Choose a reason for hiding this comment

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

@melange396 It's to run acquisition on one specific indicator. We do need it.

A bit of context: the final goal is to run acquisition immediately after each specific indicator run on Cronicle, so the database gets csv files immediately when new data is available.

Right now on Automation, acquisition runs at a specific time, on any indicators with new csv available at the time. Since acquisition process checks all indicator directories under data_dir/receiving, there's been some issue with acquisition job trying to access a indicator dir that's being written to by an indicator run at the same time on Cronicle, causing failure to both processes. This change allows the option to limit such checks to one specific indicator_dir under data_dir/receiving only.

This fix hopefully will help separate these processes as much as possible so they don't step on each other's foot.

I have tested both the optional arg and lacking thereof. test_csv_uploading.py pass in both cases, meaning if the argument is there, csv_uploading works, and if the argument is not there, csv_uploading also works, so it's pretty safe to add this optional argument.

Copy link
Collaborator

Choose a reason for hiding this comment

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

whoops! that comment was supposed to be attached to line 33 -- i was asking about the nargs argument to the add_argument() call. 🤦

Copy link
Contributor Author

@minhkhul minhkhul Mar 22, 2023

Choose a reason for hiding this comment

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

@melange396 Oh that just means it's an optional argument, so if you dont include the argument, it would still run as it does currently.

Copy link
Collaborator

Choose a reason for hiding this comment

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

specifying default does that by itself, making nargs unnecessary. i think you should take it out to avoid confusion but it doesnt break anything to leave it there. ¯\_(ツ)_/¯

Copy link
Collaborator

@melange396 melange396 left a comment

Choose a reason for hiding this comment

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

👍

help="filename for log output (defaults to stdout)")
parser.add_argument(
'--indicator_name',
nargs='?',
Copy link
Collaborator

Choose a reason for hiding this comment

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

specifying default does that by itself, making nargs unnecessary. i think you should take it out to avoid confusion but it doesnt break anything to leave it there. ¯\_(ツ)_/¯

@minhkhul minhkhul merged commit e38f4da into dev Mar 22, 2023
@minhkhul minhkhul deleted the acquisition_cronicle_change branch March 22, 2023 17:13
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.

3 participants