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

Querying of nested nodes doesn't work. #69

Open
InnocentBug opened this issue Dec 1, 2022 · 8 comments
Open

Querying of nested nodes doesn't work. #69

InnocentBug opened this issue Dec 1, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@InnocentBug
Copy link
Contributor

I am querying a nested computation node, but it doesn't seem to work correctly.

The following code is supposed to query a node, but it fails:

    host = "criptapp.org"
    token = argv[0]
    cript.API(host, token)

    comp = cript.Computation.get(url = "https://criptapp.org/api/computation/bc029f84-ca3a-493f-9b03-1e7981a13bce/")
    print(comp)

the error message is:

Traceback (most recent call last):
  File "/media/data/elwood/chimad/hongbo4/la.py", line 18, in <module>
    main(sys.argv[1:])
  File "/media/data/elwood/chimad/hongbo4/la.py", line 14, in main
    comp = cript.Computation.get(url = "https://criptapp.org/api/computation/bc029f84-ca3a-493f-9b03-1e7981a13bce/", get_level=10000)
  File "<@beartype(cript.data_model.nodes.base_node.BaseNode.get) at 0x7fbd416bac10>", line 29, in get
  File "/home/ludwig/.local/lib/python3.9/site-packages/cript/data_model/nodes/base_node.py", line 188, in get
    node._generate_nested_nodes(get_level=get_level, level=level)
  File "/home/ludwig/.local/lib/python3.9/site-packages/cript/data_model/base.py", line 126, in _generate_nested_nodes
    value[i] = node_class.get(
AttributeError: 'NoneType' object has no attribute 'get'

I am not sure if anyone can reproduce this, since the node is not public.
I would like to make it public, but I can fetch it via the SDK and I also can't update via the GUI.
So, not sure how to do this.

@InnocentBug InnocentBug added the bug Something isn't working label Dec 1, 2022
@nh916
Copy link
Contributor

nh916 commented Dec 8, 2022

I think the issue here is with the nesting.

The error shows get_level=10000:

comp = cript.Computation.get(url = "https://criptapp.org/api/computation/bc029f84-ca3a-493f-9b03-1e7981a13bce/", get_level=10000)

I think the SDK is looking to get the 1,000th nested node and can't find so it gives an error that nothing does not have a .get() method by saying "AttributeError: 'NoneType' object has no attribute 'get'"

I think this could be fixed if you explicitly set the get_level parameter to the level to 0

comp = cript.Computation.get(url = "https://criptapp.org/api/computation/bc029f84-ca3a-493f-9b03-1e7981a13bce/", get_level=0)

Please let me know if that didn't work and we can look into it further

@InnocentBug
Copy link
Contributor Author

Thanks for coming back to me.

You are right in a way.
If I set get_level=0, than the error doesn't happen.
But that doesn't really solve the problem, does it?
Because, I still don't get the full node if I set get_level=0.

How, am I supposed to know, what the right level it is that I should request the node?
Probably related to #66

Also, the code should catch this differently.
The error message is pretty bad.
Either it should tell, that you are requesting a too deep query.
Or even better, silently fix it, by not requesting further.

@InnocentBug
Copy link
Contributor Author

I don't think, I fully understand get_level and can't find a good documentation of how to use it.
The only thing, I know is that the default is 1, which also errors here.

@nh916
Copy link
Contributor

nh916 commented Dec 9, 2022

Those are all excellent points!

I can put this on my tasks list, coordinate with our project manager, and see how I can start to plan for needed improvements. There is a chance that the SDK could benefit from refactoring but I am not fully certain yet. I am open to exploring many solutions here before finding the best one for us, designing the code, and then implementing it.

As far as the errors go, I agree with you 100%, they are just unhelpful errors that do more to confuse than help.
I don't know if I want to silently fix errors for the user because that might make things less explicit and could lead to confusion down the road. My preference would be to give a clear error with here is what went wrong, and here is what might help fix the issue within the error message. The error could also show the last node at the last level before it crashed. Good documentation might also be very helpful here to diagnose and fix the issue.

Regarding getting a nested node, maybe it might be helpful if we have something like get_level="max", get_level= -1, or something that the user can set to grab the node nested at the maximum level.

Regarding the documentation of the SDK, I fully agree with you that the documentation needs a lot of improvements. This is a known issue and something that is being actively worked on by me. The SDK documentation is a bit long so as I ask for your patience as I continue to work it to get a first draft out.

If I missed anything at all please feel free to let me know and I will do my best to address them.

@InnocentBug
Copy link
Contributor Author

Thanks, that looks great.
Please keep me in the loop of where we are going here.
Thanks

@nh916
Copy link
Contributor

nh916 commented Dec 9, 2022

You got it!

@bearmit
Copy link

bearmit commented Dec 13, 2022

I would like to make it public, but I can fetch it via the SDK and I also can't update via the GUI.

Just in case: Are you certain you own all children/references nodes?

I was facing a - maybe - similar problem while trying to duplicate a Material. Its components were sometimes private so I had to skip them, it was complicated.

@InnocentBug
Copy link
Contributor Author

Yes, I own all the subnodes. So, I am sure that I should be able to change it.

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

3 participants