amakelov / mandala

A simple & elegant experiment tracking framework that integrates persistence logic & best practices directly into Python
Apache License 2.0
506 stars 15 forks source link

Exception running https://github.com/amakelov/mandala/blob/master/tutorials/00_hello.ipynb #10

Closed jkitchin closed 1 year ago

jkitchin commented 1 year ago

The last cell gives me this exception.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-11-0b8fd8fcfabb>](https://localhost:8080/#) in <cell line: 1>()
      2     a = Q() # a placeholder for a value
      3     x = inc(a) # same code as above
----> 4     y = add(21, x) # same code as above
      5     df = q.get_table(a.named('a'), x.named('x'), y.named('y'))
      6 df

5 frames
[/usr/local/lib/python3.9/dist-packages/mandala/queries/weaver.py](https://localhost:8080/#) in qwrap(obj, tp, strict)
    463     else:
    464         if strict:
--> 465             raise ValueError("value must be a `ValQuery` or `Ref`")
    466         if tp is None:
    467             tp = AnyType()

ValueError: value must be a `ValQuery` or `Ref`
amakelov commented 1 year ago

Thanks for reporting this! I'd forgotten to update the notebook in light of some recent changes.

The problem in this case is that passing raw values into functions in the with storage.query(): ... blocks like this is currently not supported - all the inputs to functions in such a block must be either placeholders (Q()) or the outputs of other functions. (EDIT) If this did work, its effect would be to pin the value of the first argument of add to 21 in the query, so that each valid matching would have to use this value. This would be useful if e.g. you are running against a persistent storage, and want to avoid loading a huge dataframe and then filtering it out, as opposed to pre-filtering (END EDIT). It is however not very difficult to add this feature - let me know if you would find it useful!

I just pushed a fix to the notebook that replaces this part with something that works - let me know if you have other questions, and thank you for your interest in the project!