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
dgl
Commits
48cc8fa8
Unverified
Commit
48cc8fa8
authored
Jun 09, 2020
by
Chao Ma
Committed by
GitHub
Jun 09, 2020
Browse files
[KVStore] Update kvstore test (#1607)
* remove freeze * update * update * fix lint * update test * update
parent
8eab08d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
tests/distributed/test_new_kvstore.py
tests/distributed/test_new_kvstore.py
+32
-1
No files found.
tests/distributed/test_new_kvstore.py
View file @
48cc8fa8
import
os
import
os
import
time
import
time
import
numpy
as
np
import
numpy
as
np
import
socket
from
scipy
import
sparse
as
spsp
from
scipy
import
sparse
as
spsp
import
dgl
import
dgl
import
backend
as
F
import
backend
as
F
...
@@ -9,6 +10,35 @@ from dgl.graph_index import create_graph_index
...
@@ -9,6 +10,35 @@ from dgl.graph_index import create_graph_index
from
numpy.testing
import
assert_array_equal
from
numpy.testing
import
assert_array_equal
if
os
.
name
!=
'nt'
:
import
fcntl
import
struct
def
get_local_usable_addr
():
"""Get local usable IP and port
Returns
-------
str
IP address, e.g., '192.168.8.12:50051'
"""
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
try
:
# doesn't even have to be reachable
sock
.
connect
((
'10.255.255.255'
,
1
))
ip_addr
=
sock
.
getsockname
()[
0
]
except
ValueError
:
ip_addr
=
'127.0.0.1'
finally
:
sock
.
close
()
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
bind
((
""
,
0
))
sock
.
listen
(
1
)
port
=
sock
.
getsockname
()[
1
]
sock
.
close
()
return
ip_addr
+
' '
+
str
(
port
)
def
create_random_graph
(
n
):
def
create_random_graph
(
n
):
arr
=
(
spsp
.
random
(
n
,
n
,
density
=
0.001
,
format
=
'coo'
)
!=
0
).
astype
(
np
.
int64
)
arr
=
(
spsp
.
random
(
n
,
n
,
density
=
0.001
,
format
=
'coo'
)
!=
0
).
astype
(
np
.
int64
)
ig
=
create_graph_index
(
arr
,
readonly
=
True
)
ig
=
create_graph_index
(
arr
,
readonly
=
True
)
...
@@ -175,7 +205,8 @@ def start_client():
...
@@ -175,7 +205,8 @@ def start_client():
@
unittest
.
skipIf
(
os
.
name
==
'nt'
or
os
.
getenv
(
'DGLBACKEND'
)
==
'tensorflow'
,
reason
=
'Do not support windows and TF yet'
)
@
unittest
.
skipIf
(
os
.
name
==
'nt'
or
os
.
getenv
(
'DGLBACKEND'
)
==
'tensorflow'
,
reason
=
'Do not support windows and TF yet'
)
def
test_kv_store
():
def
test_kv_store
():
ip_config
=
open
(
"kv_ip_config.txt"
,
"w"
)
ip_config
=
open
(
"kv_ip_config.txt"
,
"w"
)
ip_config
.
write
(
'127.0.0.1 2500 1
\n
'
)
ip_addr
=
get_local_usable_addr
()
ip_config
.
write
(
'%s 1
\n
'
%
ip_addr
)
ip_config
.
close
()
ip_config
.
close
()
pid
=
os
.
fork
()
pid
=
os
.
fork
()
if
pid
==
0
:
if
pid
==
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