Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Unique Node with software #44

Open
InnocentBug opened this issue Oct 19, 2022 · 1 comment
Open

Unique Node with software #44

InnocentBug opened this issue Oct 19, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@InnocentBug
Copy link
Contributor

Currently it is not possible to upload two softwares with the same name, but different versions.

    rdkitA = cript.Software(proj.group, "rdkit", "2020.9", "https://anaconda.org/rdkit/rdkit")
    api.save(rdkitA)
    rdkitB = cript.Software(proj.group, "rdkit", "2021.9", "https://anaconda.org/rdkit/rdkit")
    api.save(rdkitB)

should work, but it fails with:

Traceback (most recent call last):
  File "/home/ludwig/git/sim_data_model/refactor_sdk.py", line 303, in <module>
    main(sys.argv[1:])
  File "/home/ludwig/git/sim_data_model/refactor_sdk.py", line 65, in main
    api.save(rdkit)
  File "<@beartype(cript.api.API.save) at 0x7fbd061c8a60>", line 66, in save
  File "/home/ludwig/.local/lib/python3.9/site-packages/cript/api.py", line 177, in save
    raise UniqueNodeError(display_errors(response.content))
cript.exceptions.UniqueNodeError: [
    "A Software with the same name and created_by already exists: https://criptapp.org/api/software/00b0a435-b9b6-46e1-8aea-859209f42feb/."
]
@InnocentBug InnocentBug added the bug Something isn't working label Oct 19, 2022
@rjmello rjmello removed their assignment Oct 25, 2022
@InnocentBug
Copy link
Contributor Author

Update:
New Python SDK on Master branch:

this code:

    try:
        rdkit = cript.Software.get(name = "rdkit", version = "2020.9")
    except ValueError:
        rdkit = cript.Software(name = "rdkit", version = "2020.9", group=proj.group)
        rdkit.save()

Produces this error:

Traceback (most recent call last):
  File "/media/data/elwood/chimad/hongbo4/upload_cript.py", line 42, in main
    rdkit = cript.Software.get(name = "rdkit", version = "2020.9")
  File "<@beartype(cript.data_model.nodes.base_node.BaseNode.get) at 0x7f2f9612fc10>", line 29, in get
  File "/home/ludwig/.local/lib/python3.9/site-packages/cript/data_model/nodes/base_node.py", line 175, in get
    raise ValueError("Your query did not match any existing nodes.")
ValueError: Your query did not match any existing nodes.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/media/data/elwood/chimad/hongbo4/upload_cript.py", line 57, in <module>
    main(sys.argv[1:])
  File "/media/data/elwood/chimad/hongbo4/upload_cript.py", line 45, in main
    rdkit.save()
  File "<@beartype(cript.data_model.nodes.base_node.BaseNode.save) at 0x7f2f9612f670>", line 47, in save
  File "/home/ludwig/.local/lib/python3.9/site-packages/cript/data_model/nodes/base_node.py", line 78, in save
    raise UniqueNodeError(response["errors"][0])
cript.data_model.exceptions.UniqueNodeError: A Software with the same name and created_by already exists: https://criptapp.org/api/software/00b0a435-b9b6-46e1-8aea-859209f42feb/.

The reason appears to be this.

The first line fails, because there is no Software node on CRIPT that has "rdkit" as a name and version "2020.9".
That is OK!

But the second line in the except fails too.
And here it fails, because it finds a node with the name "rdkit" already in the databank.
But this node has a different version: 2021.9.
CRIPT should treat software with different versions as different and allow uploading multiple.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants