schrodinger.application.transforms.config_files module

Utilities for registering and resolving Pydantic config file paths with the job server.

When a driver script submits a job whose configuration contains file paths (FilePath, DirectoryPath), two steps are needed:

  1. Registration – in get_job_spec_from_args, call register_config_files to tell the job server which files to copy to the job directory:

    def get_job_spec_from_args(argv):
        jsb = launchapi.JobSpecificationArgsBuilder(...)
        config = MyConfig.from_yaml(args.config)
        register_config_files(jsb, config)
        ...
    
  2. Resolution – in main (the backend), call resolve_config_paths to update the model’s paths to their runtime locations:

    def main(argv=None):
        config = MyConfig.from_yaml(args.config)
        config = resolve_config_paths(config)
        ...
    

Absolute paths and paths outside the working directory are handled transparently: the job server copies them and remaps to basenames.

schrodinger.application.transforms.config_files.register_config_files(jsb: JobSpecificationArgsBuilder, model: BaseModel) None

Register file and directory paths from a Pydantic config with a job spec.

Recursively inspects fields annotated as FilePath or DirectoryPath (including Optional variants). Files are registered via setInputFile, directories via setInputDirectory.

Absolute paths and paths outside the working directory are supported: the job server copies them to the job directory and maps them to their basenames at runtime. Use resolve_config_paths in the backend to update the model’s paths to the runtime locations.

Parameters:
  • jsb – Job specification builder to register files with.

  • model – A Pydantic model instance to inspect.

schrodinger.application.transforms.config_files.resolve_config_paths(model: BaseModel) BaseModel

Resolve file and directory paths in a Pydantic config to runtime paths.

Walks the same Path-typed fields that register_config_files inspects and replaces each value with the result of jobcontrol.get_runtime_path. This is the runtime counterpart to register_config_files: the latter registers files before job submission; this function resolves them inside the backend once the job server has staged the files.

A new model instance is returned; the original is not mutated (safe for frozen models).

Parameters:

model – A Pydantic model instance whose Path fields should be resolved.

Returns:

A copy of model with runtime-resolved paths.

schrodinger.application.transforms.config_files.absolutize_paths(model: BaseModel) BaseModel

Make every path in a Pydantic config absolute.

Walks the model and replaces each Path value with its resolved absolute form, recursing into nested models, lists, and dicts. This is meant to be called in the driver so that relative paths are pinned to the driver’s working directory before the config is handed to transforms that may run elsewhere.

A new model instance is returned; the original is not mutated (safe for frozen models).

Parameters:

model – A Pydantic model instance whose Path values should be made absolute.

Returns:

A copy of model with absolute paths.