{"id":21293066,"url":"https://github.com/criteo/fromconfig-mlflow","last_synced_at":"2025-07-11T16:32:06.305Z","repository":{"id":52351941,"uuid":"360657617","full_name":"criteo/fromconfig-mlflow","owner":"criteo","description":"A fromconfig Launcher for MlFlow","archived":false,"fork":false,"pushed_at":"2022-12-28T16:59:48.000Z","size":58,"stargazers_count":3,"open_issues_count":2,"forks_count":2,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-11-08T08:49:45.689Z","etag":null,"topics":["config-as-code","fromconfig","mlflow","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/criteo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-22T19:19:49.000Z","updated_at":"2023-01-07T15:08:11.000Z","dependencies_parsed_at":"2023-01-31T06:55:12.520Z","dependency_job_id":null,"html_url":"https://github.com/criteo/fromconfig-mlflow","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/criteo%2Ffromconfig-mlflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/criteo%2Ffromconfig-mlflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/criteo%2Ffromconfig-mlflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/criteo%2Ffromconfig-mlflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/criteo","download_url":"https://codeload.github.com/criteo/fromconfig-mlflow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225741166,"owners_count":17516895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config-as-code","fromconfig","mlflow","python3"],"created_at":"2024-11-21T13:53:08.790Z","updated_at":"2024-11-21T13:53:09.269Z","avatar_url":"https://github.com/criteo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FromConfig MlFlow \u003c!-- {docsify-ignore} --\u003e\n[![pypi](https://img.shields.io/pypi/v/fromconfig-mlflow.svg)](https://pypi.python.org/pypi/fromconfig-mlflow)\n[![ci](https://github.com/criteo/fromconfig-mlflow/workflows/Continuous%20integration/badge.svg)](https://github.com/criteo/fromconfig-mlflow/actions?query=workflow%3A%22Continuous+integration%22)\n\nA [fromconfig](https://github.com/criteo/fromconfig) `Launcher` for [MlFlow](https://www.mlflow.org) support.\n\n\n\u003c!-- MarkdownTOC --\u003e\n\n- [Install](#install)\n- [Quickstart](#quickstart)\n- [MlFlow server](#mlflow-server)\n- [Configure MlFlow](#configure-mlflow)\n- [Artifacts and Parameters](#artifacts-and-parameters)\n- [Usage-Reference](#usage-reference)\n  - [`StartRunLauncher`](#startrunlauncher)\n  - [`LogArtifactsLauncher`](#logartifactslauncher)\n  - [`LogParamsLauncher`](#logparamslauncher)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n\n\u003ca id=\"install\"\u003e\u003c/a\u003e\n## Install\n\n```bash\npip install fromconfig_mlflow\n```\n\n\u003ca id=\"quickstart\"\u003e\u003c/a\u003e\n## Quickstart\n\nTo activate `MlFlow` login, simply add `--launcher.log=mlflow` to your command\n\n```bash\nfromconfig config.yaml params.yaml --launcher.log=mlflow - model - train\n```\n\nWith\n\n`model.py`\n\n```python\n\"\"\"Dummy Model.\"\"\"\n\nimport mlflow\n\n\nclass Model:\n    def __init__(self, learning_rate: float):\n        self.learning_rate = learning_rate\n\n    def train(self):\n        print(f\"Training model with learning_rate {self.learning_rate}\")\n        if mlflow.active_run():\n            mlflow.log_metric(\"learning_rate\", self.learning_rate)\n```\n\n`config.yaml`\n\n```yaml\nmodel:\n  _attr_: model.Model\n  learning_rate: \"${params.learning_rate}\"\n```\n\n`params.yaml`\n\n```yaml\nparams:\n  learning_rate: 0.001\n```\n\nIt should print\n\n```\nStarted run: http://127.0.0.1:5000/experiments/0/runs/7fe650dd99574784aec1e4b18fceb73f\nTraining model with learning_rate 0.001\n```\n\nIf you navigate to `http://127.0.0.1:5000/experiments/0/runs/7fe650dd99574784aec1e4b18fceb73f` you should see your the logged `learning_rate` metric.\n\n\u003ca id=\"mlflow-server\"\u003e\u003c/a\u003e\n## MlFlow server\n\nTo setup a local MlFlow tracking server, run\n\n```bash\nmlflow server\n```\n\nwhich should print\n\n```\n[INFO] Starting gunicorn 20.0.4\n[INFO] Listening at: http://127.0.0.1:5000\n```\n\nWe will assume that the tracking URI is `http://127.0.0.1:5000` from now on.\n\n\n\u003ca id=\"configure-mlflow\"\u003e\u003c/a\u003e\n## Configure MlFlow\n\nYou can set the tracking URI either via an environment variable or via the config.\n\nTo set the `MLFLOW_TRACKING_URI` environment variable\n\n```bash\nexport MLFLOW_TRACKING_URI=http://127.0.0.1:5000\n```\n\nAlternatively, you can set the `mlflow.tracking_uri` config key either via command line with\n\n```bash\nfromconfig config.yaml params.yaml --launcher.log=mlflow --mlflow.tracking_uri=\"http://127.0.0.1:5000\" - model - train\n```\n\nor in a config file with\n\n`launcher.yaml`\n\n```yaml\n# Configure mlflow\nmlflow:\n  # tracking_uri: \"http://127.0.0.1:5000\"  # Or set env variable MLFLOW_TRACKING_URI\n  # experiment_name: \"test-experiment\"  # Which experiment to use\n  # run_id: 12345  # To restore a previous run\n  # run_name: test  # To give a name to your new run\n  # artifact_location: \"path/to/artifacts\"  # Used only when creating a new experiment\n\n# Configure launcher\nlauncher:\n  log: mlflow\n```\n\nand run\n\n```bash\nfromconfig config.yaml params.yaml launcher.yaml - model - train\n```\n\n\u003ca id=\"artifacts-and-parameters\"\u003e\u003c/a\u003e\n## Artifacts and Parameters\n\nIn this example, we add logging of the config and parameters.\n\nRe-using the [quickstart](#quickstart) code, modify the `launcher.yaml` file\n\n```yaml\n# Configure logging\nlogging:\n  level: 20\n\n# Configure mlflow\nmlflow:\n  # tracking_uri: \"http://127.0.0.1:5000\"  # Or set env variable MLFLOW_TRACKING_URI\n  # experiment_name: \"test-experiment\"  # Which experiment to use\n  # run_id: 12345  # To restore a previous run\n  # run_name: test  # To give a name to your new run\n  # artifact_location: \"path/to/artifacts\"  # Used only when creating a new experiment\n  # include_keys:  # Only log params that match *model*\n  #   - model\n\n# Configure launcher\nlauncher:\n  log:\n    - logging\n    - mlflow\n  parse:\n    - mlflow.log_artifacts\n    - parser\n    - mlflow.log_params\n```\n\nand run\n\n```bash\nfromconfig config.yaml params.yaml launcher.yaml - model - train\n```\n\nwhich prints\n\n```\nINFO:fromconfig_mlflow.launcher:Started run: http://127.0.0.1:5000/experiments/0/runs/\u003cMLFLOW_RUN_ID\u003e\nTraining model with learning_rate 0.001\n```\n\nIf you navigate to the MlFlow run URL, you should see\n- the parameters, a flattened version of the *parsed* config (`model.learning_rate` is `0.001` and not `${params.learning_rate}`)\n- the original config, saved as `config.yaml`\n- the parsed config, saved as `parsed.yaml`\n\n\n\u003ca id=\"usage-reference\"\u003e\u003c/a\u003e\n## Usage-Reference\n\n\u003ca id=\"startrunlauncher\"\u003e\u003c/a\u003e\n### `StartRunLauncher`\n\nTo configure MlFlow, add a `mlflow` entry to your config and set the following parameters\n\n- `run_id`: if you wish to restart an existing run\n- `run_name`: if you wish to give a name to your new run\n- `tracking_uri`: to configure the tracking remote\n- `experiment_name`: to use a different experiment than the custom\n  experiment\n- `artifact_location`: the location of the artifacts (config files)\n\nAdditionally, the launcher can be initialized with the following attributes\n\n- `set_env_vars`: if True (default is `True`), set `MLFLOW_RUN_ID` and `MLFLOW_TRACKING_URI`\n- `set_run_id`: if True (default is `False`), set `mlflow.run_id` in config.\n\nFor example,\n\n```yaml\n# Configure logging\nlogging:\n  level: 20\n\n# Configure mlflow\nmlflow:\n  # tracking_uri: \"http://127.0.0.1:5000\"  # Or set env variable MLFLOW_TRACKING_URI\n  # experiment_name: \"test-experiment\"  # Which experiment to use\n  # run_id: 12345  # To restore a previous run\n  # run_name: test  # To give a name to your new run\n  # artifact_location: \"path/to/artifacts\"  # Used only when creating a new experiment\n\n# Configure Launcher\nlauncher:\n  log:\n    - logging\n    - _attr_: mlflow\n      set_env_vars: true\n      set_run_id: true\n```\n\n\n\u003ca id=\"logartifactslauncher\"\u003e\u003c/a\u003e\n### `LogArtifactsLauncher`\n\nThe launcher can be initialized with the following attributes\n\n- `path_command`: Name for the command file. If `None`, don't log the command.\n- `path_config`: Name for the config file. If `None`, don't log the config.\n\nFor example,\n\n```yaml\n# Configure logging\nlogging:\n  level: 20\n\n# Configure mlflow\nmlflow:\n  # tracking_uri: \"http://127.0.0.1:5000\"  # Or set env variable MLFLOW_TRACKING_URI\n  # experiment_name: \"test-experiment\"  # Which experiment to use\n  # run_id: 12345  # To restore a previous run\n  # run_name: test  # To give a name to your new run\n  # artifact_location: \"path/to/artifacts\"  # Used only when creating a new experiment\n\n# Configure launcher\nlauncher:\n  log:\n    - logging\n    - mlflow\n  parse:\n    - _attr_: mlflow.log_artifacts\n      path_command: launch.sh\n      path_config: config.yaml\n    - parser\n    - _attr_: mlflow.log_artifacts\n      path_command: null\n      path_config: parsed.yaml\n```\n\n\n\u003ca id=\"logparamslauncher\"\u003e\u003c/a\u003e\n### `LogParamsLauncher`\n\nThe launcher will use `include_keys` and `ignore_keys`  if present in the config in the `mlflow` key.\n\n- `ignore_keys` : If given, don't log some parameters that have some substrings.\n- `include_keys` : If given, only log some parameters that have some substrings. Also shorten the flattened parameter to start at the first match. For example, if the config is `{\"foo\": {\"bar\": 1}}` and `include_keys=(\"bar\",)`, then the logged parameter will be `\"bar\"`.\n\nFor example,\n\n```yaml\n# Configure logging\nlogging:\n  level: 20\n\n# Configure mlflow\nmlflow:\n  # tracking_uri: \"http://127.0.0.1:5000\"  # Or set env variable MLFLOW_TRACKING_URI\n  # experiment_name: \"test-experiment\"  # Which experiment to use\n  # run_id: 12345  # To restore a previous run\n  # run_name: test  # To give a name to your new run\n  # artifact_location: \"path/to/artifacts\"  # Used only when creating a new experiment\n  include_keys:  # Only log params that match *model*\n    - model\n\n# Configure launcher\nlauncher:\n  log:\n    - logging\n    - mlflow\n  parse:\n    - parser\n    - mlflow.log_params\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcriteo%2Ffromconfig-mlflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcriteo%2Ffromconfig-mlflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcriteo%2Ffromconfig-mlflow/lists"}