Skip to content

Issue with Linked KItems before dsms.commit #40

@MBueschelberger

Description

@MBueschelberger

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions