autohparams


Nameautohparams JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/NicolasMICAUX/autohparams
SummaryAutomatically create a config of hyper-parameters from global variables
upload_time2023-07-26 20:25:08
maintainer
docs_urlNone
authorNicolas Micaux
requires_python>=2.7
license
keywords hyperparameters logging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <a name="readme-top"></a>
[![Contributors][contributors-shield]][contributors-url]<!--[![Forks][forks-shield]][forks-url]-->
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]<!--[![MIT License][license-shield]][license-url]--><!--[![LinkedIn][linkedin-shield]][linkedin-url]-->
[![PyPi version][pypi-shield]][pypi-url]
[![Python 2][python2-shield]][python-url]
[![Python 3][python3-shield]][python-url]


<!-- PROJECT LOGO -->
<br />
<div align="center">

  <a href="https://github.com/NicolasMICAUX/autohparams">
    <img src="https://raw.githubusercontent.com/NicolasMICAUX/autohparams/main/images/logo.png" alt="Logo" width="160" height="160">
  </a>

  <h3 align="center">AutoHparams</h3>

  <p align="center">
    Automatically create a hparams of hyper-parameters from global variables!
    <br />
<!--
    <a href="https://github.com/NicolasMICAUX/autohparams"><strong>Explore the docs »</strong></a>
-->
    <br />
    <br />
    <a href="https://github.com/NicolasMICAUX/autohparams">View Demo</a>
    ·
    <a href="https://github.com/NicolasMICAUX/autohparams/issues">Report Bug</a>
</div>


<!-- ABOUT THE PROJECT -->
## About The Project

<!-- [Screen Shot][product-screenshot] -->

Have you ever run some machine learning training run for hours, just to realize days later that you forgot to save some hyper-parameters? So you need to pray for your memory to be good, or re-run everything?

AutoHparams is a tool that dumps every variable in the global scope of your code to a dictionary that you can save using your favorite tool. This helps to avoid 80% of the missed hyper-parameters situations.

<!-- GETTING STARTED -->
## Getting Started
Using AutoHparams is a one-liner.

Install AutoHparams with pip :
```sh
pip install autohparams
```

Import it in your code, by adding this line :
```python
from autohparams import get_auto_hparams
```

To get a hparams dictionnary, just do:  
```python
hparams = get_auto_hparams(globals())
```

**Advanced tip**  
By default, `get_auto_hparams` ignores variables whose name starts with an underscore `_`. This is convenient to filter the variables you want to include in the hparams.  
For example:
```python	
lr = 0.001  # we want to report learning rate
bs = 64     # we want to report batch size
_gpu = 0    # we don't want to report the gpu used
hparams = get_auto_hparams(globals())
```

<!-- USAGE EXAMPLES -->
## Usage
You can now use it in any framework you want, for example:  
**Tensorboard**
```python
import tensorflow as tf
from tensorboard.plugins.hparams import api as hp

with tf.summary.create_file_writer('logs/hparam_tuning').as_default():
  hp.hparams(hparams)
```

**MLflow**
```python
import mlflow

with mlflow.start_run():
  mlflow.log_params(hparams)
```

**Weights & Biases (wandb)**
```python
import wandb

wandb.init(hparams=hparams)
```

**Comet.ml**
```python
from comet_ml import Experiment

experiment = Experiment()
experiment.log_parameters(hparams)
```

**Neptune.ai**
```python
import neptune.new as neptune

run = neptune.init()

run['parameters'] = hparams
```

**Pytorch Lightning**
```python
import pytorch_lightning as pl

trainer = pl.Trainer(logger=...)
trainer.logger.log_hyperparams(hparams)
```

**Guild AI**
```python
import guild

guild.run(hparams=hparams)
```

**Polyaxon**
```python
import polyaxon_sdk

api_client = polyaxon_sdk.ApiClient()
api_client.create_hyper_params(run_uuid='uuid-of-your-run', body=hparams)
```

**ClearML**
```python
from clearml import Task

task = Task.init()
task.set_parameters(hparams)
```

**Kubeflow**
```python
from kubeflow.metadata import metadata

store = metadata.Store()
store.log_metadata(hparams)
```

#### Even faster import
If you like python wizardry, you can also import and use autohparams as a function:
```python
import autohparams
config = autohparams(globals())
```
One cannot do easier!


<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- CONTRIBUTING -->
## Contributing 
Contributions are welcome!  

<!-- ROADMAP-->
### Roadmap/todo
<!-- table with columns : task, importance, difficulty, status, description -->
<!-- 
| Task                     | Importance | Difficulty | Contributor on it | Description                                                                                                                                    |
|:-------------------------|------------|------------|-------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------|
| [Write some tests](https://github.com/NicolasMICAUX/autohparams/discussions/5)         | 4/5        | 2/5        | NOBODY            | Write some tests to ensure that the code is working properly.                                                                                  |
| [Profile code](https://github.com/NicolasMICAUX/autohparams/discussions/11)             | 2/5        | 1/5        | NOBODY            | Profile the code to see if we can speed it up a little.                                                                                        |
-->

Non-Code contribution :

| Task                     | Importance | Difficulty | Contributor on it | Description                                                                                                                                                           |
|:-------------------------|------------|------------|-------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Adding documentation](https://github.com/NicolasMICAUX/autohparams/discussions/6)     | 4/5        | 1/5        | NOBODY            | Write basic tutorials with real-life scenarios, write a wiki for other contributors to better understand the functioning of the library. |


_For every todo, just click on the link to find the discussion where I describe how I would do it._  
See the [discussions](https://github.com/NicolasMICAUX/autohparams/discussions) for a full list of proposed features (and known issues).

<p align="right">(<a href="#readme-top">back to top</a>)</p>

### How to contribute
Contributing is an awesome way to learn, inspire, and help others. Any contributions you make are **greatly appreciated**, even if it's just about styling and best practices.

If you have a suggestion that would make this project better, please fork the repo and create a pull request.  
Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/YourAmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request


## Authors
This library was created by [Nicolas MICAUX](https://github.com/NicolasMICAUX).


<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/NicolasMICAUX/autohparams.svg?style=for-the-badge
[contributors-url]: https://github.com/NicolasMICAUX/autohparams/graphs/contributors
[stars-shield]: https://img.shields.io/github/stars/NicolasMICAUX/autohparams.svg?style=for-the-badge
[stars-url]: https://github.com/NicolasMICAUX/autohparams/stargazers
[issues-shield]: https://img.shields.io/github/issues/NicolasMICAUX/autohparams.svg?style=for-the-badge
[issues-url]: https://github.com/NicolasMICAUX/autohparams/issues
[pypi-shield]: https://img.shields.io/pypi/v/searchin.svg?style=for-the-badge
[pypi-url]: https://pypi.org/project/searchin/
[python2-shield]: https://img.shields.io/badge/python-2.7+-blue.svg?style=for-the-badge
[python3-shield]: https://img.shields.io/badge/python-3.5+-blue.svg?style=for-the-badge
[python-url]: https://www.python.org/downloads/

[//]: # ([license-shield]: https://img.shields.io/github/license/NicolasMICAUX/autohparams.svg?style=for-the-badge)
[//]: # ([license-url]: https://github.com/NicolasMICAUX/autohparams/blob/master/LICENSE.txt)
[//]: # ([linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555)
[//]: # ([linkedin-url]: https://linkedin.com/in/othneildrew)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NicolasMICAUX/autohparams",
    "name": "autohparams",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "hyperparameters,logging",
    "author": "Nicolas Micaux",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/48/be/1c3c5adea917b19091f529053285e76e93c1746e7f2ba72b07fb42efc439/autohparams-0.1.0.tar.gz",
    "platform": null,
    "description": "<a name=\"readme-top\"></a>\n[![Contributors][contributors-shield]][contributors-url]<!--[![Forks][forks-shield]][forks-url]-->\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]<!--[![MIT License][license-shield]][license-url]--><!--[![LinkedIn][linkedin-shield]][linkedin-url]-->\n[![PyPi version][pypi-shield]][pypi-url]\n[![Python 2][python2-shield]][python-url]\n[![Python 3][python3-shield]][python-url]\n\n\n<!-- PROJECT LOGO -->\n<br />\n<div align=\"center\">\n\n  <a href=\"https://github.com/NicolasMICAUX/autohparams\">\n    <img src=\"https://raw.githubusercontent.com/NicolasMICAUX/autohparams/main/images/logo.png\" alt=\"Logo\" width=\"160\" height=\"160\">\n  </a>\n\n  <h3 align=\"center\">AutoHparams</h3>\n\n  <p align=\"center\">\n    Automatically create a hparams of hyper-parameters from global variables!\n    <br />\n<!--\n    <a href=\"https://github.com/NicolasMICAUX/autohparams\"><strong>Explore the docs \u00bb</strong></a>\n-->\n    <br />\n    <br />\n    <a href=\"https://github.com/NicolasMICAUX/autohparams\">View Demo</a>\n    \u00b7\n    <a href=\"https://github.com/NicolasMICAUX/autohparams/issues\">Report Bug</a>\n</div>\n\n\n<!-- ABOUT THE PROJECT -->\n## About The Project\n\n<!-- [Screen Shot][product-screenshot] -->\n\nHave you ever run some machine learning training run for hours, just to realize days later that you forgot to save some hyper-parameters? So you need to pray for your memory to be good, or re-run everything?\n\nAutoHparams is a tool that dumps every variable in the global scope of your code to a dictionary that you can save using your favorite tool. This helps to avoid 80% of the missed hyper-parameters situations.\n\n<!-- GETTING STARTED -->\n## Getting Started\nUsing AutoHparams is a one-liner.\n\nInstall AutoHparams with pip :\n```sh\npip install autohparams\n```\n\nImport it in your code, by adding this line :\n```python\nfrom autohparams import get_auto_hparams\n```\n\nTo get a hparams dictionnary, just do:  \n```python\nhparams = get_auto_hparams(globals())\n```\n\n**Advanced tip**  \nBy default, `get_auto_hparams` ignores variables whose name starts with an underscore `_`. This is convenient to filter the variables you want to include in the hparams.  \nFor example:\n```python\t\nlr = 0.001  # we want to report learning rate\nbs = 64     # we want to report batch size\n_gpu = 0    # we don't want to report the gpu used\nhparams = get_auto_hparams(globals())\n```\n\n<!-- USAGE EXAMPLES -->\n## Usage\nYou can now use it in any framework you want, for example:  \n**Tensorboard**\n```python\nimport tensorflow as tf\nfrom tensorboard.plugins.hparams import api as hp\n\nwith tf.summary.create_file_writer('logs/hparam_tuning').as_default():\n  hp.hparams(hparams)\n```\n\n**MLflow**\n```python\nimport mlflow\n\nwith mlflow.start_run():\n  mlflow.log_params(hparams)\n```\n\n**Weights & Biases (wandb)**\n```python\nimport wandb\n\nwandb.init(hparams=hparams)\n```\n\n**Comet.ml**\n```python\nfrom comet_ml import Experiment\n\nexperiment = Experiment()\nexperiment.log_parameters(hparams)\n```\n\n**Neptune.ai**\n```python\nimport neptune.new as neptune\n\nrun = neptune.init()\n\nrun['parameters'] = hparams\n```\n\n**Pytorch Lightning**\n```python\nimport pytorch_lightning as pl\n\ntrainer = pl.Trainer(logger=...)\ntrainer.logger.log_hyperparams(hparams)\n```\n\n**Guild AI**\n```python\nimport guild\n\nguild.run(hparams=hparams)\n```\n\n**Polyaxon**\n```python\nimport polyaxon_sdk\n\napi_client = polyaxon_sdk.ApiClient()\napi_client.create_hyper_params(run_uuid='uuid-of-your-run', body=hparams)\n```\n\n**ClearML**\n```python\nfrom clearml import Task\n\ntask = Task.init()\ntask.set_parameters(hparams)\n```\n\n**Kubeflow**\n```python\nfrom kubeflow.metadata import metadata\n\nstore = metadata.Store()\nstore.log_metadata(hparams)\n```\n\n#### Even faster import\nIf you like python wizardry, you can also import and use autohparams as a function:\n```python\nimport autohparams\nconfig = autohparams(globals())\n```\nOne cannot do easier!\n\n\n<p align=\"right\">(<a href=\"#readme-top\">back to top</a>)</p>\n\n<!-- CONTRIBUTING -->\n## Contributing \nContributions are welcome!  \n\n<!-- ROADMAP-->\n### Roadmap/todo\n<!-- table with columns : task, importance, difficulty, status, description -->\n<!-- \n| Task                     | Importance | Difficulty | Contributor on it | Description                                                                                                                                    |\n|:-------------------------|------------|------------|-------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------|\n| [Write some tests](https://github.com/NicolasMICAUX/autohparams/discussions/5)         | 4/5        | 2/5        | NOBODY            | Write some tests to ensure that the code is working properly.                                                                                  |\n| [Profile code](https://github.com/NicolasMICAUX/autohparams/discussions/11)             | 2/5        | 1/5        | NOBODY            | Profile the code to see if we can speed it up a little.                                                                                        |\n-->\n\nNon-Code contribution :\n\n| Task                     | Importance | Difficulty | Contributor on it | Description                                                                                                                                                           |\n|:-------------------------|------------|------------|-------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Adding documentation](https://github.com/NicolasMICAUX/autohparams/discussions/6)     | 4/5        | 1/5        | NOBODY            | Write basic tutorials with real-life scenarios, write a wiki for other contributors to better understand the functioning of the library. |\n\n\n_For every todo, just click on the link to find the discussion where I describe how I would do it._  \nSee the [discussions](https://github.com/NicolasMICAUX/autohparams/discussions) for a full list of proposed features (and known issues).\n\n<p align=\"right\">(<a href=\"#readme-top\">back to top</a>)</p>\n\n### How to contribute\nContributing is an awesome way to learn, inspire, and help others. Any contributions you make are **greatly appreciated**, even if it's just about styling and best practices.\n\nIf you have a suggestion that would make this project better, please fork the repo and create a pull request.  \nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/YourAmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\n## Authors\nThis library was created by [Nicolas MICAUX](https://github.com/NicolasMICAUX).\n\n\n<!-- MARKDOWN LINKS & IMAGES -->\n<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->\n[contributors-shield]: https://img.shields.io/github/contributors/NicolasMICAUX/autohparams.svg?style=for-the-badge\n[contributors-url]: https://github.com/NicolasMICAUX/autohparams/graphs/contributors\n[stars-shield]: https://img.shields.io/github/stars/NicolasMICAUX/autohparams.svg?style=for-the-badge\n[stars-url]: https://github.com/NicolasMICAUX/autohparams/stargazers\n[issues-shield]: https://img.shields.io/github/issues/NicolasMICAUX/autohparams.svg?style=for-the-badge\n[issues-url]: https://github.com/NicolasMICAUX/autohparams/issues\n[pypi-shield]: https://img.shields.io/pypi/v/searchin.svg?style=for-the-badge\n[pypi-url]: https://pypi.org/project/searchin/\n[python2-shield]: https://img.shields.io/badge/python-2.7+-blue.svg?style=for-the-badge\n[python3-shield]: https://img.shields.io/badge/python-3.5+-blue.svg?style=for-the-badge\n[python-url]: https://www.python.org/downloads/\n\n[//]: # ([license-shield]: https://img.shields.io/github/license/NicolasMICAUX/autohparams.svg?style=for-the-badge)\n[//]: # ([license-url]: https://github.com/NicolasMICAUX/autohparams/blob/master/LICENSE.txt)\n[//]: # ([linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555)\n[//]: # ([linkedin-url]: https://linkedin.com/in/othneildrew)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Automatically create a config of hyper-parameters from global variables",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/NicolasMICAUX/autohparams"
    },
    "split_keywords": [
        "hyperparameters",
        "logging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48be1c3c5adea917b19091f529053285e76e93c1746e7f2ba72b07fb42efc439",
                "md5": "2c807945aff45215076ca0ad6007c5f2",
                "sha256": "b2d4940fb83c9962743bfaaa1f0a11de57a4946f02b195375cd0c8687194bf79"
            },
            "downloads": -1,
            "filename": "autohparams-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2c807945aff45215076ca0ad6007c5f2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 5334,
            "upload_time": "2023-07-26T20:25:08",
            "upload_time_iso_8601": "2023-07-26T20:25:08.424338Z",
            "url": "https://files.pythonhosted.org/packages/48/be/1c3c5adea917b19091f529053285e76e93c1746e7f2ba72b07fb42efc439/autohparams-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-26 20:25:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NicolasMICAUX",
    "github_project": "autohparams",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "autohparams"
}
        
Elapsed time: 0.10287s