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

Strange behaviour of CUDS remove #638

Closed
paulzierep opened this issue May 20, 2021 · 4 comments · Fixed by #659
Closed

Strange behaviour of CUDS remove #638

paulzierep opened this issue May 20, 2021 · 4 comments · Fixed by #659
Assignees
Labels

Comments

@paulzierep
Copy link

paulzierep commented May 20, 2021

In the following case, shouldn't the object be removed from the DB ?

with SqliteWrapperSession("A.db") as session_A:
    wrapper = cuba.Wrapper(session=session_A)

    wrapper.add(cuba.Entity(), rel=cuba.activeRelationship)

    session_A.commit()

with SqliteWrapperSession("A.db") as session_A:
    wrapper = cuba.Wrapper(session=session_A)

    for cuds in wrapper.iter():
        wrapper.remove(cuds)
        #wrapper.session.delete_cuds_object(cuds)

    session_A.commit()

with SqliteWrapperSession("A.db") as session_A:
    wrapper = cuba.Wrapper(session=session_A)

    pretty_print(wrapper)

##################################################

- Cuds object:
  uuid: 5b4726ff-bff5-401e-9ffa-a8cf2f2d4033
  type: cuba.Wrapper
  superclasses: cuba.Entity, cuba.Wrapper
  description: 
    The root of all wrappers. These are the bridge to simulation engines and databases.

   |_Relationship cuba.activeRelationship:
     -  cuba.Entity cuds object:
        uuid: 938f89ee-2819-4695-a886-2e270663598f

If I use the wrapper.session.delete_cuds_object(cuds) function
pretty_print(wrapper) drows an arrow:

  File "session_exchange/remove_from_DB.py", line 36, in <module>
    pretty_print(wrapper)
  File "osp/core/utils/pretty_print.py", line 27, in pretty_print
    pp += _pp_subelements(cuds_object)
  File "osp/core/utils/pretty_print.py", line 74, in _pp_subelements
    key=lambda x: (str(x[0].oclass), str(x[1]),
  File "osp/core/cuds.py", line 375, in iter
    yield from ((r, m) for m in mapping[r.uid])
AttributeError: 'NoneType' object has no attribute 'uid'

How can I remove a CUDS from the DB ?

@yoavnash
Copy link
Member

yoavnash commented May 20, 2021

Could be related to #624. @kysrpex What do you think?

@paulzierep
Copy link
Author

Yes it seems that wrapper.session.delete_cuds_object is related to #624.
But how about wrapper.remove(cuds) should it not remove the object from the wrapper ?

@pablo-de-andres
Copy link
Member

For completeness, could you add the whole error stack from the pretty_print?

@paulzierep
Copy link
Author

Updated my comment

@yoavnash yoavnash added this to the v3.5.4-beta milestone Jun 9, 2021
@kysrpex kysrpex linked a pull request Jun 16, 2021 that will close this issue
kysrpex added a commit that referenced this issue Jul 15, 2021
Allow the CUDS objects to be initialized with extra triples, instead of having to add them after already having created the object.

This solves #668 because previously, the class of the `Wrapper` CUDS objects was not defined on the server until after having spawned the CUDS object, because it is created empty and then filled with triples. This caused it to go to the added buffer, ignoring the changes introduced in #638, which solved the issue for local sessions, for which the CUDS objects are not created first empty and then filled with triples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants