-
Notifications
You must be signed in to change notification settings - Fork 2
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
Provide access to code of providers via pipeline object #98
Comments
I would suggest (for now) to simply add We need to think about how to handle parameters. Currently they are wrapped in a lambda, but even if they are not, getting the docstring of a type defined via Adding |
That was part of the motivation. So, yes, I think we should do
And the |
Actually, there is no need to use the import inspect
import sciline
def inspect_provider(p: sciline.pipeline.Provider):
print(f'--{p.kind}--')
if p.kind == 'function':
print(p.func)
print(inspect.getsource(p.func))
elif p.kind == 'parameter':
print('value:', p.call({}))
# else: something internal that should probably not be inspected
def f(x: int) -> str:
return str(x)
l = lambda: 3.0
l.__annotations__['return'] = float
pl = sciline.Pipeline((f, l), params={int: 2})
inspect_provider(pl._providers[int])
inspect_provider(pl._providers[str])
inspect_provider(pl._providers[float]) Prints
Lambdas are weird... |
In many situations, it is handy to have access to the source of certain
providers
within a given pipeline in read-only mode.While the
visualize()
functionality is already convenient for getting an overview of the pipeline, the internals of the providers are hidden, possibly even in a multilevel module.I propose a new method which prints the path, docstring, and source of the provider, like:
where
CleanedData
is the key to the provider.Under the hood, one should be able to do all the magic using the
inspect
python package.Another maybe more fancy idea is to show the docstring of
providers
in the TaskGraph as tooltips and maybe the same for type definitions of domain types.Best
Daniel
The text was updated successfully, but these errors were encountered: