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:
Registration – in
get_job_spec_from_args, callregister_config_filesto 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) ...
Resolution – in
main(the backend), callresolve_config_pathsto 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
FilePathorDirectoryPath(includingOptionalvariants). Files are registered viasetInputFile, directories viasetInputDirectory.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_pathsin 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 thatregister_config_filesinspects and replaces each value with the result ofjobcontrol.get_runtime_path. This is the runtime counterpart toregister_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
frozenmodels).- Parameters:
model – A Pydantic model instance whose
Pathfields 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
Pathvalue 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
frozenmodels).- Parameters:
model – A Pydantic model instance whose
Pathvalues should be made absolute.- Returns:
A copy of model with absolute paths.