-
Notifications
You must be signed in to change notification settings - Fork 2
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
staging: run recipes from firebase #179
Conversation
* formatting
…m/mesoscope/cellpack into feature/run-recipes-from-firebase
af55458
to
a928c1d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #179 +/- ##
==========================================
+ Coverage 98.52% 98.63% +0.10%
==========================================
Files 16 18 +2
Lines 476 511 +35
==========================================
+ Hits 469 504 +35
Misses 7 7 ☔ View full report in Codecov by Sentry. |
3c0bbf1
to
a928c1d
Compare
…ture/run-recipes-from-firebase
…ture/run-recipes-from-firebase
* turn off resolving inheritance while uploading * able to upload recipes having "inherit" key * get download and pack to work, refactors needed * refactors
…ture/run-recipes-from-firebase
…m/mesoscope/cellpack into feature/run-recipes-from-firebase
…ture/run-recipes-from-firebase
* refactor AWS and firebase handler * databases initiation handling
8dcc36c
to
3e691a2
Compare
In this PR, I’d appreciate your focus on reviewing three main parts:
Also, sorry for mixing the already-reviewed features with the awaiting-review features in one PR. I’ll manage my PR flow better moving forward to make it easier for everyone to review. |
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.
Can you add instructions to create firebase credentials somewhere? These could be a page in the wiki that can be linked elsewhere.
The updated README is in the upload local recipes to s3
PR - #189, you can view the instructions here: https://github.com/mesoscope/cellpack/pull/189/files
So after some discussion and having addressed the changes, the recommended PR merge order should be: #191 - #189 - (WIP) run recipes with "inherit" key - #179, feel free to review the first two when you have time. I'll convert this PR to a draft for now. Sorry for the confusion!
Maybe we could also add the link to create firebase credentials in the prompt to provide the credentials path?
return json.load(file_name) | ||
|
||
|
||
def write_json_file(path, data): |
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.
This will overwrite existing files at the path. Would it make sense to add an option for checking this?
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 just found out that we have checks for existing keys and contents(like user and firebase creds) before calling this function. So it should be safe to leave this method in its original form.
and "all_partners" in obj["partners"] | ||
and not obj["partners"]["all_partners"] | ||
) | ||
else obj.get("partners", []) |
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.
for recipes downloaded from a remote db, do we expect this to work if obj["partners"]["all_partners"]
is not empty?
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.
Thank you for asking this! The if statement here is to determine whether the recipes retrieved from firebase have partners. During the upload process, the key "all_partners" is added to "partners" of each obj no matter there is partner or not.
The structure of the partners in Firebase is as follows:
- for recipes without partners:
obj[partners] == {'all_partners': []}
- for recipes with partners:
obj[partners] == {'all_partners': [<cellpack.autopack.interface_objects.partners.Partner object at xyz>]}
if "gradients" in recipe_data: | ||
# gradients in firebase recipes are already stored as a list of dicts | ||
if "gradients" in recipe_data and not isinstance( | ||
recipe_data["gradients"], list |
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.
Do we need to initialize GradientData
instances from the existing list of dictionaries on firebase? i.e. loop over the list (instead of a dict) and instantiate?
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.
Just like with Partners
, the cellpack system organizes gradients
into a list during the upload process. Therefore, we can skip processing gradients in firebase recipes.
def test_is_nested_list(): | ||
assert DataDoc.is_nested_list([]) is False | ||
assert DataDoc.is_nested_list([[], []]) is True | ||
assert DataDoc.is_nested_list([[1, 2], [3, 4]]) is True |
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.
Should DataDoc.is_nested_list([1, [1, 2]])
be True
or False
?
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.
Good thought! Currently it returns False, though it should return True. While we don't typically encounter such nested lists like [1, [1, 2]] in our recipe data, but you are right that our method should be robust enough to handle all types of nested lists. I just modified the function to run a loop, should be good this time.
Looks good overall! I was able to upload and run the gradient recipe remotely. Thanks for adding detailed tests and documentation :) |
Good idea! We are going to refactor the the authentication methods to integrate firebase credentials in issue #214 |
Co-authored-by: Saurabh Mogre <saurabh.mogre@alleninstitute.org>
…m/mesoscope/cellpack into feature/run-recipes-from-firebase
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.
@mogres Thank you for your thorough review! I've just addressed several issues. Please feel free to point out any additional edge cases or concerns that I may overlooked.
and "all_partners" in obj["partners"] | ||
and not obj["partners"]["all_partners"] | ||
) | ||
else obj.get("partners", []) |
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.
Thank you for asking this! The if statement here is to determine whether the recipes retrieved from firebase have partners. During the upload process, the key "all_partners" is added to "partners" of each obj no matter there is partner or not.
The structure of the partners in Firebase is as follows:
- for recipes without partners:
obj[partners] == {'all_partners': []}
- for recipes with partners:
obj[partners] == {'all_partners': [<cellpack.autopack.interface_objects.partners.Partner object at xyz>]}
if "gradients" in recipe_data: | ||
# gradients in firebase recipes are already stored as a list of dicts | ||
if "gradients" in recipe_data and not isinstance( | ||
recipe_data["gradients"], list |
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.
Just like with Partners
, the cellpack system organizes gradients
into a list during the upload process. Therefore, we can skip processing gradients in firebase recipes.
def test_is_nested_list(): | ||
assert DataDoc.is_nested_list([]) is False | ||
assert DataDoc.is_nested_list([[], []]) is True | ||
assert DataDoc.is_nested_list([[1, 2], [3, 4]]) is True |
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.
Good thought! Currently it returns False, though it should return True. While we don't typically encounter such nested lists like [1, [1, 2]] in our recipe data, but you are right that our method should be robust enough to handle all types of nested lists. I just modified the function to run a loop, should be good this time.
Problem
What is the problem this work solves, including
closes #167
Solution
This is a staging branch for run recipes from firebase.
features in this branch that need to be reviewed:
already reviewed:
Type of change
Please delete options that are not relevant.
Steps to Verify:
upload -r examples/recipes/v2/gradients.json
pack -r firebase:recipes/gradients_v_default -c examples/packing-configs/run.json
Keyfiles (delete if not relevant):
DBRecipeHandler.py
autopack/__init__.py