Flavien
11/10/2021, 2:10 PMfrom dagster import GraphDefinition, In, Nothing, op, repository
@op(ins={"deps": In(Nothing)})
def say_hello(context):
<http://context.log.info|context.log.info>("Hello!")
def say_hello_graph() -> GraphDefinition:
return GraphDefinition(
"say_hello",
node_defs=[
say_hello.alias("say_hello_1"),
say_hello.alias("say_hello_2")
],
)
say_hello_job = say_hello_graph().to_job()
@repository
def say_hello_repository():
return [say_hello_job]
But I'm getting this error:
AttributeError: 'PendingNodeInvocation' object has no attribute '__name__'
File "/home/flavi/playground/dagster/.venv/lib/python3.9/site-packages/dagster/grpc/server.py", line 205, in __init__
self._repository_symbols_and_code_pointers.load()
File "/home/flavi/playground/dagster/.venv/lib/python3.9/site-packages/dagster/grpc/server.py", line 90, in load
self._loadable_repository_symbols = load_loadable_repository_symbols(
File "/home/flavi/playground/dagster/.venv/lib/python3.9/site-packages/dagster/grpc/server.py", line 108, in load_loadable_repository_symbols
loadable_targets = get_loadable_targets(
File "/home/flavi/playground/dagster/.venv/lib/python3.9/site-packages/dagster/grpc/utils.py", line 25, in get_loadable_targets
else loadable_targets_from_python_file(python_file, working_directory)
File "/home/flavi/playground/dagster/.venv/lib/python3.9/site-packages/dagster/core/workspace/autodiscovery.py", line 17, in loadable_targets_from_python_file
loaded_module = load_python_file(python_file, working_directory)
File "/home/flavi/playground/dagster/.venv/lib/python3.9/site-packages/dagster/core/code_pointer.py", line 123, in load_python_file
module = import_module_from_path(module_name, python_file)
File "/home/flavi/playground/dagster/.venv/lib/python3.9/site-packages/dagster/seven/__init__.py", line 50, in import_module_from_path
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/flavi/playground/dagster/sandbox.py", line 18, in <module>
say_hello_job = say_hello_graph().to_job()
File "/home/flavi/playground/dagster/sandbox.py", line 10, in say_hello_graph
return GraphDefinition(
File "/home/flavi/playground/dagster/.venv/lib/python3.9/site-packages/dagster/core/definitions/graph.py", line 138, in __init__
self._node_defs = _check_node_defs_arg(name, node_defs)
File "/home/flavi/playground/dagster/.venv/lib/python3.9/site-packages/dagster/core/definitions/graph.py", line 84, in _check_node_defs_arg
name=graph_name, func=node_def.__name__
I'm I doing something wrong ?owen
11/10/2021, 5:27 PM.alias()
on an OpDefinition changes its type to something that GraphDefinition is not expecting. I'll file an issue for this. For now, if you need to construct a GraphDefinition programmatically (and have multiple of the same op), you could use an op factory to sidestep this issue:
def get_say_hello(name):
@op(name=name, ins={"deps": In(Nothing)})
def _op(context):
<http://context.log.info|context.log.info>("Hello!")
return _op
def say_hello_graph() -> GraphDefinition:
return GraphDefinition(
name="say_hello",
node_defs=[get_say_hello("say_hello_1"), get_say_hello("say_hello_2")],
)
Flavien
11/10/2021, 5:27 PMowen
11/10/2021, 5:34 PM