Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master #286

Merged
merged 4 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions docs/en_US/nnicli_ref.rst

This file was deleted.

3 changes: 1 addition & 2 deletions docs/en_US/sdk_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ Python API Reference

Auto Tune <autotune_ref>
NAS <NAS/NasReference>
Compression Utilities <Compression/CompressionReference>
NNI Client <nnicli_ref>
Compression Utilities <Compression/CompressionReference>
3 changes: 1 addition & 2 deletions nni/experiment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

from .config import *
from .experiment import Experiment

from .nni_client import *
from .data import *
135 changes: 135 additions & 0 deletions nni/experiment/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
from dataclasses import dataclass
import json
from typing import List


@dataclass
class TrialResult:
"""
TrialResult stores the result information of a trial job.

Attributes
----------
parameter: dict
Hyper parameters for this trial.
value: serializable object, usually a number, or a dict with key "default" and other extra keys
Final result.
trialJobId: str
Trial job id.
"""
parameter: dict
value: dict
trialJobId: str

def __init__(self, parameter: dict, value: str, trialJobId: str):
self.parameter = parameter
self.value = json.loads(value)
self.trialJobId = trialJobId


@dataclass
class TrialMetricData:
"""
TrialMetricData stores the metric data of a trial job.
A trial job may have both intermediate metric and final metric.

Attributes
----------
timestamp: int
Time stamp.
trialJobId: str
Trial job id.
parameterId: int
Parameter id.
type: str
Metric type, `PERIODICAL` for intermediate result and `FINAL` for final result.
sequence: int
Sequence number in this trial.
data: serializable object, usually a number, or a dict with key "default" and other extra keys
Metric data.
"""
timestamp: int
trialJobId: str
parameterId: int
type: str
sequence: int
data: dict

def __init__(self, timestamp: int, trialJobId: str, parameterId: int, type: str, sequence: int, data: str): # pylint: disable=W0622
self.timestamp = timestamp
self.trialJobId = trialJobId
self.parameterId = parameterId
self.type = type
self.sequence = sequence
self.data = json.loads(json.loads(data))


@dataclass
class TrialHyperParameters:
"""
TrialHyperParameters stores the hyper parameters of a trial job.

Attributes
----------
parameter_id: int
Parameter id.
parameter_source: str
Parameter source.
parameters: dict
Hyper parameters.
parameter_index: int
Parameter index.
"""
parameter_id: int
parameter_source: str
parameters: dict
parameter_index: int


@dataclass
class TrialJob:
"""
TrialJob stores the information of a trial job.

Attributes
----------
trialJobId: str
Trial job id.
status: str
Job status.
hyperParameters: list of `nni.experiment.TrialHyperParameters`
See `nni.experiment.TrialHyperParameters`.
logPath: str
Log path.
startTime: int
Job start time (timestamp).
endTime: int
Job end time (timestamp).
finalMetricData: list of `nni.experiment.TrialMetricData`
See `nni.experiment.TrialMetricData`.
stderrPath: str
Stderr log path.
sequenceId: int
Sequence Id.
"""
trialJobId: str
status: str
hyperParameters: List[TrialHyperParameters]
logPath: str
startTime: int
endTime: int
finalMetricData: List[TrialMetricData]
stderrPath: str
sequenceId: int

def __init__(self, trialJobId: str, status: str, logPath: str, startTime: int, sequenceId: int,
endTime: int = -1, stderrPath: str = '', hyperParameters: List = [], finalMetricData: List = []):
self.trialJobId = trialJobId
self.status = status
self.hyperParameters = [TrialHyperParameters(**json.loads(e)) for e in hyperParameters]
self.logPath = logPath
self.startTime = startTime
self.endTime = endTime
self.finalMetricData = [TrialMetricData(**e) for e in finalMetricData]
self.stderrPath = stderrPath
self.sequenceId = sequenceId
Loading