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

Add dict to ionic_steps typing #5

Merged
merged 3 commits into from
Aug 23, 2024

Conversation

orionarcher
Copy link

By adding "ionic_steps" to DATA_OBJECTS it changes the possible types. This is a small fix for that

@orionarcher
Copy link
Author

@esoteric-ephemera I made a small oversight in my last PR, this should fix it.

@esoteric-ephemera
Copy link
Owner

Hey Orion, I think I may have fixed this separately, can you double check that the ionic_steps are correctly stored as blobs?

@orionarcher
Copy link
Author

I just pulled the recent changes and I think this fix is still necessary. I am still getting an error when trying to reconstitute the doc as a pydantic object. Broadening the type to include dict fixed it for me.

dict_doc = doc["output"]
task_doc = ForceFieldTaskDocument.parse_obj(dict_doc)
Traceback (most recent call last):
  File "/Users/orioncohen/miniforge3/envs/radical/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-4-ba8e139772af>", line 8, in <module>
    task_doc = ForceFieldTaskDocument.parse_obj(dict_doc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/orioncohen/miniforge3/envs/radical/lib/python3.11/site-packages/pydantic/main.py", line 1135, in parse_obj
    return cls.model_validate(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/orioncohen/miniforge3/envs/radical/lib/python3.11/site-packages/pydantic/main.py", line 568, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ForceFieldTaskDocument
output.ionic_steps
  Input should be a valid list [type=list_type, input_value={'@class': '', '@module':...48118', 'store': 'data'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.8/v/list_type

@esoteric-ephemera
Copy link
Owner

Very strange - I'm not getting these errors trying to reconstruct the doc (tried a few pydantic v2.7.x and 2.8.x) and ionic steps should be a list of dict when deserialized. Can you double check that doc["output"]["output"]["ionic_steps"] is a list or null, and that ForcefieldTaskDoc(**doc["output"]) also hydrates correctly?

@orionarcher
Copy link
Author

Do you have an additional data store configured in your test environment? If not, we won't see the same behavior. I am getting ionic_steps saved as a reference to it's location in the additional store:

>>> doc["output"]["output"]["ionic_steps"]
{'@class': '',
 '@module': '',
 'blob_uuid': '3e24b30f-97f3-40db-aeb7-266e0ca48118',
 'store': 'data'}

I checked and ForcefieldTaskDoc(**doc["output"]) hydrates correctly.

@esoteric-ephemera
Copy link
Owner

Oh OK I see - specifying "output.ionic_steps" in the additional store data does not actually push ionic_steps to blob storage, but "ionic_steps" does

@esoteric-ephemera esoteric-ephemera merged commit 73caa68 into esoteric-ephemera:ase Aug 23, 2024
9 checks passed
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.

2 participants