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
Feature/node probe #463
Feature/node probe #463
Conversation
@jmilloy could you please spare a few minutes to review and merge when happy. |
…emoving depency on cache for Compositor case.
@jmilloy let me know if/when you are happy and I'll merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I just had one question about the OrderedCompositer active loop.
I added a test for the case I'm concerned about. Now I think I get what you are doing (you check the source values and mark the source active if it matches the orderedcompositor value), so I was able to make a test that fails. See d812b92. |
Hold on, I jumped the gun. Just a sec. |
Oh True... I see what you mean... Yeah, if two sources give the same value they would both be marked active. That does need a fix. |
Okay, I fixed the test. It now fails only because of the active flag. |
ok, let me fix it. |
It was a bit tricky because if two OrderedCompositor sources are the same (not object, but definition/hash), only one of them shows up in the compositor definition. So of course only one shows up in the probe output. I'm not sure if that should be considered a bug or a feature! >>> a = podpac.data.Array(source=np.ones(3), coordinates=podpac.Coordinates([[0, 1, 2]], dims=['time']))
>>> b = podpac.data.Array(source=np.ones(3), coordinates=podpac.Coordinates([[0, 1, 2]], dims=['time']))
>>> c = podpac.compositor.OrderedCompositor(sources=[a, b])
>>> c.probe(time=1)
OrderedDict([('Array', {'active': True, 'value': 1.0, 'inputs': [], 'name': 'Array', 'node_hash': 'e032d95041f8076a2a6317c079ace615'}), ('OrderedCompositor', {'active': True, 'value': 1.0, 'inputs': ['Array', 'Array'], 'name': 'OrderedCompositor', 'node_hash': '98354d0bc306ec5c8657590e04c0969a'})]) |
Here's another fun one. Fails because the class isn't available in the global scope: >>> def fn():
... class AnotherOne(podpac.algorithm.Algorithm):
... def algorithm(self, inputs, coordinates):
... return self.create_output_array(coordinates, data=1)
... c = podpac.compositor.OrderedCompositor(sources=[a, b, AnotherOne()])
... c.probe(time=1)
...
>>> fn()
Traceback (most recent call last):
File "/home/jmilloy/Creare/Pipeline/podpac/podpac/core/node.py", line 816, in from_definition
node_class = getattr(module, node_name)
AttributeError: module '__main__' has no attribute 'AnotherOne'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in fn
File "/home/jmilloy/Creare/Pipeline/podpac/podpac/core/node.py", line 418, in probe
return probe_node(self, lat, lon, time, alt)
File "/home/jmilloy/Creare/Pipeline/podpac/podpac/core/utils.py", line 556, in probe_node
n = podpac.Node.from_definition(d)
File "/home/jmilloy/Creare/Pipeline/podpac/podpac/core/node.py", line 818, in from_definition
raise ValueError(
ValueError: Invalid definition for node 'AnotherOne': class 'AnotherOne' not found in module '__main__' In the test, I had to define the Again, not sure if this is a bug or just the way things are... |
I'll call it a feature. :) Fixed in d938580 Thanks for flagging. |
Adds a utility method to probe a node/pipeline at a point. It evaluates EVERY node in the pipeline, even if it is not being used.
See the unit tests for expected usage.