Cornerstone-OnDemand/modelkit

Easy way to override asset for local development?

Closed this issue · 2 comments

Is there an easy way to override an asset in a config specifically for development / non-production purposes?

Ideally, a way to do this on the local machine by copying an existing config, and setting the asset path to a local directory. Even if before it pointed to a remote path.

For example, maybe support for asset: "file:///test/path/to/asset" which then bypasses the asset resolver? Could potentially be enabled through an environment variable, like MODELKIT_ALLOW_DEBUG_ASSETS=1

Closing, missed this:

model_name:
    asset: asset/name:1.0/[file.ext]
    model_settings:
        # including this line will override the above (the above syntax must still be valid, otherwise it causes a crash)
        asset_path: /local/path/to/asset/file.ext

# If the asset is overriden in the model_settings
if "asset_path" in model_settings:
asset_path = model_settings.pop("asset_path")
logger.debug(
"Overriding asset from Model settings",
model_name=model_name,
asset_path=asset_path,
)
self.assets_info[configuration.asset] = AssetInfo(path=asset_path)

It is also possible to specify an environment variable to override the file or version based on the model name:

# If the model's asset is overriden with environment variables
venv = "MODELKIT_{}_FILE".format(
re.sub(r"[\/\-\.]+", "_", asset_spec.name).upper()
)

# possibly override version
venv = "MODELKIT_{}_VERSION".format(
re.sub(r"[\/\-\.]+", "_", asset_spec.name).upper()
)