Add Click support info (#49)

This commit is contained in:
pollfly 2021-08-24 12:51:57 +03:00 committed by GitHub
parent 0767ffdd85
commit fda3f1ea3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,9 +14,12 @@ These sections are further broken down into sub-sections (General \ Args \ TF_De
![image](../img/hyperparameters_sections.png) ![image](../img/hyperparameters_sections.png)
## Argument Parser ## Command Line Parsing
Parameters passed to experiments, using Python's built-in argparser module, are automatically captured by ClearML, so no code ClearML captures any command line parameters passed when invoking code that uses standard python packages such as
changes are needed. argparse or [click](https://click.palletsprojects.com). This happens automatically with no additional code required beyond
initializing ClearML.
### Argparse Example
```python ```python
from clearml import Task from clearml import Task
@ -31,6 +34,28 @@ args = parser.parse_args()
task = Task.init(project_name="examples",task_name="argparser logging") task = Task.init(project_name="examples",task_name="argparser logging")
``` ```
### Click Example
```python
from clearml import Task
import click
task = Task.init(project_name='examples', task_name='click single command')
@click.command()
@click.option('--count', default=1, help='Number of greetings.')
@click.option('--name', prompt='Your name',
help='The person to greet.')
def hello(count, name):
for x in range(count):
click.echo("Hello {}!".format(name))
hello()
```
See another code example [here](https://github.com/allegroai/clearml/blob/master/examples/frameworks/click/click_multi_cmd.py).
## Connecting Objects ## Connecting Objects
Users can directly connect objects, such as dictionaries or even custom classes, to Tasks. Users can directly connect objects, such as dictionaries or even custom classes, to Tasks.