nnicli_ref.md 1.3 KB
Newer Older
Junwei Sun's avatar
Junwei Sun committed
1
2
3
4
5
# NNI Client

NNI client is a python API of `nnictl`, which implements the most commonly used commands. Users can use this API to control their experiments, collect experiment results and conduct advanced analyses based on experiment results in python code directly instead of using command line. Here is an example:

```
6
from nni.experiment import Experiment
Junwei Sun's avatar
Junwei Sun committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

# create an experiment instance
exp = Experiment() 

# start an experiment, then connect the instance to this experiment
# you can also use `resume_experiment`, `view_experiment` or `connect_experiment`
# only one of them should be called in one instance
exp.start_experiment('nni/examples/trials/mnist-pytorch/config.yml', port=9090)

# update the experiment's concurrency
exp.update_concurrency(3)

# get some information about the experiment
print(exp.get_experiment_status())
print(exp.get_job_statistics())
print(exp.list_trial_jobs())

# stop the experiment, then disconnect the instance from the experiment.
exp.stop_experiment()
```

## References

```eval_rst
31
..  autoclass:: nni.experiment.Experiment
Junwei Sun's avatar
Junwei Sun committed
32
    :members:
33
..  autoclass:: nni.experiment.TrialJob
Junwei Sun's avatar
Junwei Sun committed
34
    :members:
35
..  autoclass:: nni.experiment.TrialHyperParameters
Junwei Sun's avatar
Junwei Sun committed
36
    :members:
37
..  autoclass:: nni.experiment.TrialMetricData
Junwei Sun's avatar
Junwei Sun committed
38
    :members:
39
..  autoclass:: nni.experiment.TrialResult
Junwei Sun's avatar
Junwei Sun committed
40
41
    :members:
```