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

Issue with Linked KItems before dsms.commit #40

Open
MBueschelberger opened this issue Nov 13, 2024 · 0 comments
Open

Issue with Linked KItems before dsms.commit #40

MBueschelberger opened this issue Nov 13, 2024 · 0 comments

Comments

@MBueschelberger
Copy link
Member

MBueschelberger commented Nov 13, 2024

In this case, we are considering a workflow without commiting (yet).

After the validation, a linked kitem is referenced as LinkedKItem object when appending to the linked_kitem property of a KItem object (seems legit).

item.linked_kitems = [another_item]
assert isinstance(item.linked_kitems[0], LinkedKItem)

When another kitem is appended in afterwards, the latest implementation fails:

item.linked_kitems += [yet_another_item]

Traceback:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\BUE\al-alloy-aging-use-case\al_alloy_aging\integrate.py", line 251, in <module>
    integrate()
  File "C:\Users\BUE\al-alloy-aging-use-case\al_alloy_aging\integrate.py", line 229, in integrate
    treatment.linked_kitems = [before_specimen_kitem, after_specimen_kitem] + [linked for linked in treatment.linked_kitems]
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Anaconda3\envs\sdk\Lib\site-packages\dsms\knowledge\kitem.py", line 230, in __setattr__
    super().__setattr__(name, value)
  File "C:\Anaconda3\envs\sdk\Lib\site-packages\pydantic\main.py", line 817, in __setattr__
    self.__pydantic_validator__.validate_assignment(self, name, value)
pydantic_core._pydantic_core.ValidationError: 1 validation error for KItem
linked_kitems
  Value error, KItem with uuid `3799baf3-ff56-4dab-b8a5-eeed3f6dfe4f` does not exist in
            DSMS-instance `https://bue.materials-data.space/` [type=value_error, input_value=[KItem(

        name = Specimen...
                        updated_at: None
                ], input_type=list]
    For further information visit https://errors.pydantic.dev/2.7/v/value_error

This is because a linked kitem is not commited to the backend yet and the validator tries to download it.

A better solution would be to add a lookup from the buffers before trying to download from the remote backend.

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

No branches or pull requests

1 participant