diff --git a/docs/easy_reading.rst b/docs/easy_reading.rst index a0e1fab..0ddf07f 100644 --- a/docs/easy_reading.rst +++ b/docs/easy_reading.rst @@ -183,8 +183,7 @@ The dataframe's column names correspond to the fields contained in :samp:`reade - **Metadata columns:** They represent the options contained in the YAML files :samp:`config.yaml` and :samp:`info.yaml`. The column names are constructed as dot-separated flattened keys of the hierarchical options contained in the YAML files :samp:`config.yaml` and :samp:`info.yaml` preceded by the prefixes :samp:`config` or :samp:`info`. - **Metrics columns:** They represent the content of the metrics dictionaries stored using the method :samp:`log_metrics` and wich are stored in JSON files under the :samp:`metrics` directory (ex :samp:`metrics/train.json`). The column names are constructed using the metrics dictionary keys preceded by the file name containing them as a prefix (ex: :samp:`train.loss`). Each field of a metrics column is a list of all values taken by a particular key accross all the metrics dictionaries stored in a given JSON file. -- **Artifact columns:** They represent the content of the artifacts stored using the method :samp:`log_artifacts` or :samp:`log_checkpoint` and which are stored in the :samp:`artifacts` directory. -The column names are constructed as a dot-separed version of the relative parent path of each artifact w.r.t. log directory (ie: :samp:`artifact/artifact_type/path/to/parent_dir` becomes :samp:`artifact.artifact_type.path.to.parent_dir`). For more details on loading artifacts, see the section :ref:`loading_artifacts`. +- **Artifact columns:** They represent the content of the artifacts stored using the method :samp:`log_artifacts` or :samp:`log_checkpoint` and which are stored in the :samp:`artifacts` directory. The column names are constructed as a dot-separed version of the relative parent path of each artifact w.r.t. log directory (ie: :samp:`artifact/artifact_type/path/to/parent_dir` becomes :samp:`artifact.artifact_type.path.to.parent_dir`). For more details on loading artifacts, see the section :ref:`loading_artifacts`. As you can see, the dataframe loads the content of all keys in the files :samp:`train.json` (contained in the :samp:`metrics` directories of each run), which might not be desirable if these files are large. This can be avoided using **lazy evaluation** which we describe next. diff --git a/mlxp/data_structures/schemas.py b/mlxp/data_structures/schemas.py index cbd05b2..0ceb877 100644 --- a/mlxp/data_structures/schemas.py +++ b/mlxp/data_structures/schemas.py @@ -234,9 +234,7 @@ class MLXPConfig: - If untracked files should be added. - If uncommitted changes should be committed. - - If a copy of the current repository based on the latest commit should be made - (if not already existing) to execute the code from there. - Otherwise, code is executed from the current directory. + - If a copy of the current repository based on the latest commit should be made (if not already existing) to execute the code from there. Otherwise, code is executed from the current directory. 2. If 'interactive_mode==False', no interactive mode is used and current options are used: diff --git a/mlxp/launcher.py b/mlxp/launcher.py index 9679ba5..30c3909 100644 --- a/mlxp/launcher.py +++ b/mlxp/launcher.py @@ -75,8 +75,8 @@ def launch( :samp:`launch` allows composing configurations from multiple configuration files by leveraging hydra (see hydra-core package). This function behaves similarly to :samp:`hydra.main` provided in the hydra-core package: - https://github.com/facebookresearch/hydra/blob/main/hydra/main.py. - It expects a path to a configuration file named 'config.yaml' + https://github.com/facebookresearch/hydra/blob/main/hydra/main.py. + It expects a path to a configuration file named :samp:`config.yaml` contained in the directory :samp:`config_path` and returns a decorator. The returned decorator expects functions with the following signature: :samp:`main(ctx: mlxp.Context)`. @@ -105,8 +105,7 @@ def main(ctx: mlxp.Context)->None: This function is necessary to enable MLXP's functionalities including: 1. Multiple submissions to a cluster queue using :samp:`mlxpsub` - 2. Job versioning: Creating a 'safe' working directory from which jobs are executed when submitted to a cluster queue, - to ensure each job was executed with a specific version of the code. + 2. Job versioning: Creating a 'safe' working directory from which jobs are executed when submitted to a cluster queue, to ensure each job was executed with a specific version of the code. :param config_path: The config path, a directory where the default user configuration and MLXP settings are stored. :param seeding_function: A callable for setting the seed of random number generators. It is called with the seed option in 'ctx.config.seed' passed to it. diff --git a/mlxp/logger.py b/mlxp/logger.py index f11d881..72fc719 100644 --- a/mlxp/logger.py +++ b/mlxp/logger.py @@ -170,19 +170,17 @@ def log_artifacts(self, artifact: object, artifact_name: str, artifact_type: str def load_artifacts( self, artifact_name: str, artifact_type: Union[str, None] = None, root: Union[str, None] = None ) -> Any: - """Restore an artifact from 'log_dir/artifacts/artifact_type/artifact_name' or a - user defined directory root. + """Restore an artifact from 'log_dir/artifacts/artifact_type/artifact_name' or a user defined directory root. Raises an error if it fails to do so. :param artifact_name: Name of the file where the checkpoint is saved. + :param root: Absolute path to the log directory (log_dir) (assuming it was created using a logger object). If set to None, then the logger in its own log_dir. + :param artifact_type: Type of the artifact to save. If set to None, the method will try to infer the artifact type from the artifact_name. :type artifact_name: str (default 'checkpoint') - :param root: Absolute path to the log directory (log_dir) (assuming it was created using a logger object). - If set to None, then the logger in its own log_dir. - :param artifact_type: Type of the artifact to save. - If set to None, the method will try to infer the artifact type from the artifact_name. :type root: Union[str,None] (default 'None') :type artifact_type: Union[str,None] (default 'None') + return: Any serializable object stored in 'root/artifacts/artifact_type/artifact_name'. rtype: Any """ @@ -342,16 +340,15 @@ def log_checkpoint(self, checkpoint: Any, log_name: str = "checkpoint") -> None: self.log_artifacts(checkpoint, artifact_name=log_name, artifact_type="pickle") def load_checkpoint(self, log_name, root=None) -> Any: - """Restore a checkpoint from 'run_dir/artifacts/pickle/log_name.pkl' or a user - defined directory root. + """Restore a checkpoint from 'run_dir/artifacts/pickle/log_name.pkl' or a user defined directory root. Raises an error if it fails to do so. :param log_name: Name of the file where the checkpoint is saved. :type log_name: str (default 'checkpoint') - :param root: Absolute path to the checkpoint. - If set to None, the logger looks for the checkpoint in 'run_dir/artifacts/pickle'. + :param root: Absolute path to the checkpoint. If set to None, the logger looks for the checkpoint in 'run_dir/artifacts/pickle'. :type root: Union[str,None] (default 'None') + return: Any serializable object stored in 'run_dir/artifacts/pickle/last.pkl'. rtype: Any """ diff --git a/mlxp/version_manager.py b/mlxp/version_manager.py index e73f291..00406fa 100644 --- a/mlxp/version_manager.py +++ b/mlxp/version_manager.py @@ -48,8 +48,7 @@ def _set_im_handler(self, im_handler: Any) -> None: @abc.abstractmethod def get_info(self) -> Dict[str, Any]: - """Return a dictionary containing information about the version used for the - run. + """Return a dictionary containing information about the version used for the run. :return: Dictionary containing information about the version used for the run. :rtype: Dict[str, Any] @@ -98,16 +97,14 @@ def __init__(self, parent_work_dir: str, compute_requirements: bool): self.requirements = ["UNKNOWN"] def get_info(self) -> Dict[str, Any]: - """Return a dictionary containing information about the version used for the - run. + """Return a dictionary containing information about the version used for the run. The following information is returned: - requirements: the dependencies of the code and their versions. Empty if no requirements file was found. - commit_hash: The hash of the latest commit. - repo_path: Path to the repository. - :return: Dictionary containing - information about the version used for the run. + :return: Dictionary containing information about the version used for the run. :rtype: Dict[str, Any] """ return { @@ -122,8 +119,8 @@ def make_working_directory(self) -> str: Depending on the user's choice, the returned directory is either: - The current working directory. - - A directory under self.parent_work_dir/repo_name/latest_commit_hash. - In this case, a copy of the code based on the latest git commit is created and used to run the experiment. + - A directory under self.parent_work_dir/repo_name/latest_commit_hash. + In this case, a copy of the code based on the latest git commit is created and used to run the experiment. :rtype: str :return: A path to the target working directory diff --git a/run_checks.sh b/run_checks.sh index 725b3b5..24534b8 100755 --- a/run_checks.sh +++ b/run_checks.sh @@ -32,7 +32,7 @@ if ! $skip_tests; then conda create -n mlxp_env_$version python=$version -y pip install pytest pip install torch - fi + fic #source mlxp_env_$version/bin/activate source activate mlxp_env_$version