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

fix: convert "type" Enums to strings in v1 recipe for firebase upload duplication check #231

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

rugeli
Copy link
Collaborator

@rugeli rugeli commented Feb 14, 2024

Problem

What is the problem this work solves, including
Found a bug: a v1 recipe could be uploaded to firebase more than once

This issue arises because, during the version migration process, the "type" attribute of an object is converted into an Enum, whereas it is stored as a string in firebase database. So our duplication checking logic always find a difference in data types.

difference:

{
  "type_changes": {
    "root['type']": {
      "old_type": "<class 'str'>",
      "new_type": "<enum 'INGREDIENT_TYPE'>",
      "old_value": "single_sphere",
      "new_value": "<INGREDIENT_TYPE.SINGLE_SPHERE: 'single_sphere'>"
    }
  }
}

Solution

What I/we did to solve this problem
I added a value check for enum in the existing method prep_data_for_db within DBRecipeHandler

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Steps to Verify:

  1. in DBRecipeHandler.py, comment out the return in DBUploader > upload_recipe() to let deeper system checks into objects and compositions
  2. run upload -r examples/recipes/v1/one_sphere.json to upload the recipe to your dev database
  3. repeat the upload command to verify that the duplication check correctly identifies each object and composition, preventing duplicate uploads

Copy link

github-actions bot commented Feb 14, 2024

Packing analysis report

Analysis for packing results located at cellpack/tests/outputs/test_spheres/spheresSST

Ingredient name Encapsulating radius Average number packed
ext_A 25 236.0

Packing image

Packing image

Distance analysis

Expected minimum distance: 50.00
Actual minimum distance: 50.01

Ingredient key Pairwise distance distribution
ext_A Distance distribution ext_A

@rugeli rugeli requested review from meganrm and mogres February 14, 2024 22:48
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (72ecf15) 98.63% compared to head (e9661ff) 98.63%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #231   +/-   ##
=======================================
  Coverage   98.63%   98.63%           
=======================================
  Files          18       18           
  Lines         511      511           
=======================================
  Hits          504      504           
  Misses          7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@mogres mogres left a comment

Choose a reason for hiding this comment

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

Good catch! Apologies it took so long to review.

@rugeli rugeli merged commit 2893482 into main Feb 22, 2024
7 checks passed
@rugeli rugeli deleted the fix/v1-recipe-upload branch February 22, 2024 17:47
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.

4 participants