Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
382e2761
Unverified
Commit
382e2761
authored
Jul 24, 2019
by
Guoxin
Committed by
GitHub
Jul 24, 2019
Browse files
Merge pull request #1353 from suiguoxin/get_id
issue #1331
parents
a5fa2351
14d16cc3
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
1 deletion
+41
-1
docs/en_US/sdk_reference.rst
docs/en_US/sdk_reference.rst
+2
-0
src/nni_manager/training_service/local/localTrainingService.ts
...ni_manager/training_service/local/localTrainingService.ts
+4
-1
src/sdk/pynni/nni/env_vars.py
src/sdk/pynni/nni/env_vars.py
+1
-0
src/sdk/pynni/nni/platform/local.py
src/sdk/pynni/nni/platform/local.py
+6
-0
src/sdk/pynni/nni/platform/standalone.py
src/sdk/pynni/nni/platform/standalone.py
+6
-0
src/sdk/pynni/nni/platform/test.py
src/sdk/pynni/nni/platform/test.py
+6
-0
src/sdk/pynni/nni/trial.py
src/sdk/pynni/nni/trial.py
+10
-0
src/sdk/pynni/tests/test_trial.py
src/sdk/pynni/tests/test_trial.py
+6
-0
No files found.
docs/en_US/sdk_reference.rst
View file @
382e2761
...
...
@@ -8,6 +8,8 @@ Trial
.. autofunction:: nni.get_current_parameter
.. autofunction:: nni.report_intermediate_result
.. autofunction:: nni.report_final_result
.. autofunction:: nni.get_experiment_id
.. autofunction:: nni.get_trial_id
.. autofunction:: nni.get_sequence_id
...
...
src/nni_manager/training_service/local/localTrainingService.ts
View file @
382e2761
...
...
@@ -26,7 +26,7 @@ import * as path from 'path';
import
*
as
ts
from
'
tail-stream
'
;
import
*
as
tkill
from
'
tree-kill
'
;
import
{
NNIError
,
NNIErrorNames
}
from
'
../../common/errors
'
;
import
{
getInitTrialSequenceId
}
from
'
../../common/experimentStartupInfo
'
;
import
{
getExperimentId
,
getInitTrialSequenceId
}
from
'
../../common/experimentStartupInfo
'
;
import
{
getLogger
,
Logger
}
from
'
../../common/log
'
;
import
{
HostJobApplicationForm
,
HyperParameters
,
JobApplicationForm
,
TrainingService
,
TrialJobApplicationForm
,
...
...
@@ -126,6 +126,7 @@ class LocalTrainingService implements TrainingService {
private
stopping
:
boolean
;
private
rootDir
!
:
string
;
private
trialSequenceId
:
number
;
private
readonly
experimentId
!
:
string
;
private
gpuScheduler
!
:
GPUScheduler
;
private
readonly
occupiedGpuIndexNumMap
:
Map
<
number
,
number
>
;
private
designatedGpuIndices
!
:
Set
<
number
>
;
...
...
@@ -145,6 +146,7 @@ class LocalTrainingService implements TrainingService {
this
.
stopping
=
false
;
this
.
log
=
getLogger
();
this
.
trialSequenceId
=
-
1
;
this
.
experimentId
=
getExperimentId
();
this
.
jobStreamMap
=
new
Map
<
string
,
ts
.
Stream
>
();
this
.
log
.
info
(
'
Construct local machine training service.
'
);
this
.
occupiedGpuIndexNumMap
=
new
Map
<
number
,
number
>
();
...
...
@@ -400,6 +402,7 @@ class LocalTrainingService implements TrainingService {
resource
:
{
gpuIndices
:
number
[]
}):
{
key
:
string
;
value
:
string
}[]
{
const
envVariables
:
{
key
:
string
;
value
:
string
}[]
=
[
{
key
:
'
NNI_PLATFORM
'
,
value
:
'
local
'
},
{
key
:
'
NNI_EXP_ID
'
,
value
:
this
.
experimentId
},
{
key
:
'
NNI_SYS_DIR
'
,
value
:
trialJobDetail
.
workingDirectory
},
{
key
:
'
NNI_TRIAL_JOB_ID
'
,
value
:
trialJobDetail
.
id
},
{
key
:
'
NNI_OUTPUT_DIR
'
,
value
:
trialJobDetail
.
workingDirectory
},
...
...
src/sdk/pynni/nni/env_vars.py
View file @
382e2761
...
...
@@ -24,6 +24,7 @@ from collections import namedtuple
_trial_env_var_names
=
[
'NNI_PLATFORM'
,
'NNI_EXP_ID'
,
'NNI_TRIAL_JOB_ID'
,
'NNI_SYS_DIR'
,
'NNI_OUTPUT_DIR'
,
...
...
src/sdk/pynni/nni/platform/local.py
View file @
382e2761
...
...
@@ -94,5 +94,11 @@ def send_metric(string):
else
:
subprocess
.
run
([
'touch'
,
_metric_file
.
name
],
check
=
True
)
def
get_experiment_id
():
return
trial_env_vars
.
NNI_EXP_ID
def
get_trial_id
():
return
trial_env_vars
.
NNI_TRIAL_JOB_ID
def
get_sequence_id
():
return
trial_env_vars
.
NNI_TRIAL_SEQ_ID
src/sdk/pynni/nni/platform/standalone.py
View file @
382e2761
...
...
@@ -25,6 +25,12 @@ import json_tricks
def
get_next_parameter
():
pass
def
get_experiment_id
():
pass
def
get_trial_id
():
pass
def
get_sequence_id
():
pass
...
...
src/sdk/pynni/nni/platform/test.py
View file @
382e2761
...
...
@@ -32,6 +32,12 @@ _last_metric = None
def
get_next_parameter
():
return
_params
def
get_experiment_id
():
return
'fakeidex'
def
get_trial_id
():
return
'fakeidtr'
def
get_sequence_id
():
return
0
...
...
src/sdk/pynni/nni/trial.py
View file @
382e2761
...
...
@@ -30,11 +30,15 @@ __all__ = [
'get_current_parameter'
,
'report_intermediate_result'
,
'report_final_result'
,
'get_experiment_id'
,
'get_trial_id'
,
'get_sequence_id'
]
_params
=
None
_experiment_id
=
platform
.
get_experiment_id
()
_trial_id
=
platform
.
get_trial_id
()
_sequence_id
=
platform
.
get_sequence_id
()
...
...
@@ -52,6 +56,12 @@ def get_current_parameter(tag):
return
None
return
_params
[
'parameters'
][
tag
]
def
get_experiment_id
():
return
_experiment_id
def
get_trial_id
():
return
_trial_id
def
get_sequence_id
():
return
_sequence_id
...
...
src/sdk/pynni/tests/test_trial.py
View file @
382e2761
...
...
@@ -38,6 +38,12 @@ class TrialTestCase(TestCase):
nni
.
get_next_parameter
()
self
.
assertEqual
(
nni
.
get_current_parameter
(
'x'
),
123
)
def
test_get_experiment_id
(
self
):
self
.
assertEqual
(
nni
.
get_experiment_id
(),
'fakeidex'
)
def
test_get_trial_id
(
self
):
self
.
assertEqual
(
nni
.
get_trial_id
(),
'fakeidtr'
)
def
test_get_sequence_id
(
self
):
self
.
assertEqual
(
nni
.
get_sequence_id
(),
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment