Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
51c6afde
Unverified
Commit
51c6afde
authored
Jun 24, 2021
by
liuzhe-lz
Committed by
GitHub
Jun 24, 2021
Browse files
change ipv4 detection method (#3860)
Co-authored-by:
liuzhe
<
zhe.liu@microsoft.com
>
parent
27e123df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
26 deletions
+13
-26
dependencies/required.txt
dependencies/required.txt
+0
-1
nni/tools/nnictl/config_schema.py
nni/tools/nnictl/config_schema.py
+0
-9
ts/nni_manager/common/utils.ts
ts/nni_manager/common/utils.ts
+13
-16
No files found.
dependencies/required.txt
View file @
51c6afde
astor
hyperopt == 0.1.2
json_tricks
netifaces
psutil
pyyaml
requests
...
...
nni/tools/nnictl/config_schema.py
View file @
51c6afde
...
...
@@ -5,7 +5,6 @@ import json
import
logging
import
os
import
netifaces
from
schema
import
And
,
Optional
,
Or
,
Regex
,
Schema
,
SchemaError
from
nni.tools.package_utils
import
(
create_validator_instance
,
...
...
@@ -493,7 +492,6 @@ class NNIConfigSchema:
self
.
validate_tuner_adivosr_assessor
(
experiment_config
)
self
.
validate_pai_trial_conifg
(
experiment_config
)
self
.
validate_kubeflow_operators
(
experiment_config
)
self
.
validate_eth0_device
(
experiment_config
)
self
.
validate_hybrid_platforms
(
experiment_config
)
self
.
validate_frameworkcontroller_trial_config
(
experiment_config
)
...
...
@@ -599,13 +597,6 @@ class NNIConfigSchema:
print_warning
(
warning_information
.
format
(
'outputDir'
))
self
.
validate_pai_config_path
(
experiment_config
)
def
validate_eth0_device
(
self
,
experiment_config
):
'''validate whether the machine has eth0 device'''
if
experiment_config
.
get
(
'trainingServicePlatform'
)
not
in
[
'local'
]
\
and
not
experiment_config
.
get
(
'nniManagerIp'
)
\
and
'eth0'
not
in
netifaces
.
interfaces
():
raise
SchemaError
(
'This machine does not contain eth0 network device, please set nniManagerIp in config file!'
)
def
validate_hybrid_platforms
(
self
,
experiment_config
):
required_config_name_map
=
{
'remote'
:
'machineList'
,
...
...
ts/nni_manager/common/utils.ts
View file @
51c6afde
...
...
@@ -8,6 +8,7 @@ import { randomBytes } from 'crypto';
import
*
as
cpp
from
'
child-process-promise
'
;
import
*
as
cp
from
'
child_process
'
;
import
{
ChildProcess
,
spawn
,
StdioOptions
}
from
'
child_process
'
;
import
*
as
dgram
from
'
dgram
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
net
from
'
net
'
;
import
*
as
os
from
'
os
'
;
...
...
@@ -217,28 +218,24 @@ function cleanupUnitTest(): void {
setExperimentStartupInfo
(
true
,
'
unittest
'
,
8080
,
'
unittest
'
,
undefined
,
logLevel
);
}
let
cachedipv4Address
:
string
=
''
;
let
cachedIpv4Address
:
string
|
null
=
null
;
/**
* Get IPv4 address of current machine
* Get IPv4 address of current machine
.
*/
function
getIPV4Address
():
string
{
if
(
cached
i
pv4Address
&&
cachedipv4Address
.
length
>
0
)
{
return
cached
i
pv4Address
;
if
(
cached
I
pv4Address
!==
null
)
{
return
cached
I
pv4Address
;
}
const
networkInterfaces
=
os
.
networkInterfaces
();
if
(
networkInterfaces
.
eth0
)
{
for
(
const
item
of
networkInterfaces
.
eth0
)
{
if
(
item
.
family
===
'
IPv4
'
)
{
cachedipv4Address
=
item
.
address
;
return
cachedipv4Address
;
}
}
}
else
{
throw
Error
(
`getIPV4Address() failed because os.networkInterfaces().eth0 is undefined. Please specify NNI manager IP in config.`
);
}
// creates "udp connection" to a non-exist target, and get local address of the connection.
// since udp is connectionless, this does not send actual packets.
const
socket
=
dgram
.
createSocket
(
'
udp4
'
);
socket
.
connect
(
1
,
'
192.0.2.0
'
);
cachedIpv4Address
=
socket
.
address
().
address
;
socket
.
close
();
throw
Error
(
'
getIPV4Address() failed because no valid IPv4 address found.
'
)
return
cachedIpv4Address
;
}
/**
...
...
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