Kyle Gobel
06/02/2023, 1:11 PMclass Server(ConfigurableResource):
server_name: str
def ping_server(self):
print("pinging server " + self.server_name)
@op
def interact_with_server(context, server: Server):
server.ping_server()
@graph
def do_stuff():
interact_with_server()
do_stuff_staging = do_stuff.to_job(name="do_stuff_staging", resource_defs={"server": Server(server_name="staging")})
do_stuff_prod = do_stuff.to_job(name="do_stuff_prod", resource_defs={"server": Server(server_name="prod")})
When including those jobs in the Definitions I'm getting "resource with key 'server' requied by op 'interact_with_server' not provided. Please provide resource to key 'server', or change it one of the following keys [ list of all my top level resources ]Qwame
06/02/2023, 1:29 PMKyle Gobel
06/02/2023, 1:31 PMto_job
call (the resource_defs
parameter)Kyle Gobel
06/02/2023, 1:35 PMdefs = Definitions(
assets=[asset1, assetb],
jobs=[do_stuff_staging, do_stuff_prod],
resources=[global_resource_a, global_resource_b]
)
But I thought that should work -- without placing the resource server
in the definitions -- otherwise what's the point of the resource_defs
parameter on the to_job
functionclaire
06/07/2023, 4:36 PMDefinitions
object are bound to assets. Jobs must already have resources bound at creation time and do not respect the resources provided top level.Qwame
06/07/2023, 4:47 PMDefinitions
were bound to jobs as well? Hence I have removed BindResourcestoJobs
from my projectclaire
06/07/2023, 4:50 PMKyle Gobel
06/07/2023, 4:54 PMKyle Gobel
06/07/2023, 4:55 PMclaire
06/07/2023, 5:01 PMclass Server(ConfigurableResource):
server_name: str
def ping_server(self):
print("pinging server " + self.server_name)
class MyUnrelatedResource(ConfigurableResource):
my_field: str
@op
def interact_with_server(context, server: Server):
server.ping_server()
@graph
def do_stuff():
interact_with_server()
do_stuff_staging = do_stuff.to_job(
name="do_stuff_staging", resource_defs={"server": Server(server_name="staging")}
)
do_stuff_prod = do_stuff.to_job(
name="do_stuff_prod", resource_defs={"server": Server(server_name="prod")}
)
@asset(required_resource_keys={"global_resource_a"})
def asset1():
return 1
@asset(required_resource_keys={"global_resource_a"})
def assetb():
return 1
# elsewhere
defs = Definitions(
assets=[asset1, assetb],
jobs=[do_stuff_staging, do_stuff_prod],
resources={
"global_resource_a": MyUnrelatedResource(my_field="alsdjaksld"),
},
)
Kyle Gobel
06/12/2023, 1:01 AMKyle Gobel
06/12/2023, 1:21 AM# elsewhere
defs = Definitions(
assets=[asset1, assetb],
jobs=[do_stuff_staging, do_stuff_prod, job_with_global_resource],
resources={
"global_resource_a": MyUnrelatedResource(my_field="alsdjaksld"),
"io_manager": fs_io_manager,
},
)
Kyle Gobel
06/12/2023, 1:23 AMKyle Gobel
06/12/2023, 1:25 AMclaire
06/13/2023, 8:56 PMKyle Gobel
06/14/2023, 6:18 PM