Hey again! Is there any way to supply a dynamic io...
# integration-snowflake
s
Hey again! Is there any way to supply a dynamic io_manager_key to an asset? Specifically I want to switch between using a staging database in snowflake and a production one. I'm wrapping a group of assets in a
define_asset_job
object and passing a config, but it seems you are only able to pass config entries to the ops?
j
would something like this work? may have some syntax errors (i wrote it in slack)
Copy code
@asset(
   io_manager_key="snowflake_io_mgr"
)
def my_asset():
    ...

define_asset_job(name="staging_job", selection=[my_asset], resource_defs={"snowflake_io_mgr": snowflake_io_manager.configured(<staging_config>))

define_asset_job(name="prod_job", selection=[my_asset], resource_defs={"snowflake_io_mgr": snowflake_io_manager.configured(<prd_config>))
s
Hmm - just tried this, and it looks like
define_asset_job
doesn't have a
resource_defs
param
j
ah yeah you’re totally right. i shouldnt try to write code from memory haha. can you try this instead?
Copy code
@asset(
   io_manager_key="snowflake_io_mgr"
)
def my_asset():
    ...

define_asset_job(name="staging_job", selection=[my_asset], config={"resources": {"snowflake_io_mgr":{<staging_config}}})

define_asset_job(name="prod_job", selection=[my_asset], config={"resources": {"snowflake_io_mgr":{<staging_config}}})
if your repository/definitions when you set up the mapping of resource to resource key, you won’t use the
.configured
api, instead all the configuration will be provided as the
config
arg in
define_asset_job
s
Something is still slightly off - but it feels close! It's saying that my
fs_io_manager
is required by the first op, but not provided. What would make it recognize the resource in the
Definitions
class, but not in the config?
j
can you share your
define_asset_job
and your
Definitions
?
s
I'll shoot you a DM!
ty spinny 1