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
20d5062a
"include/ck/utility/array.hpp" did not exist on "9d59a39af303d9ef9a08bdf7d492ddfca33304ea"
Unverified
Commit
20d5062a
authored
Aug 27, 2020
by
SparkSnail
Committed by
GitHub
Aug 27, 2020
Browse files
Fix tracking url in AML (#2830)
parent
3d2abd4a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
15 deletions
+50
-15
src/nni_manager/training_service/reusable/aml/amlClient.ts
src/nni_manager/training_service/reusable/aml/amlClient.ts
+21
-15
src/nni_manager/training_service/reusable/test/amlClient.test.ts
..._manager/training_service/reusable/test/amlClient.test.ts
+29
-0
No files found.
src/nni_manager/training_service/reusable/aml/amlClient.ts
View file @
20d5062a
...
@@ -74,13 +74,11 @@ export class AMLClient {
...
@@ -74,13 +74,11 @@ export class AMLClient {
throw
Error
(
'
python shell client not initialized!
'
);
throw
Error
(
'
python shell client not initialized!
'
);
}
}
this
.
pythonShellClient
.
send
(
'
tracking_url
'
);
this
.
pythonShellClient
.
send
(
'
tracking_url
'
);
let
trackingUrl
=
''
;
this
.
pythonShellClient
.
on
(
'
message
'
,
(
status
:
any
)
=>
{
this
.
pythonShellClient
.
on
(
'
message
'
,
function
(
status
:
any
)
{
const
trackingUrl
=
this
.
parseContent
(
'
tracking_url
'
,
status
);
const
items
=
status
.
split
(
'
:
'
);
if
(
trackingUrl
!==
''
)
{
if
(
items
[
0
]
===
'
tracking_url
'
)
{
deferred
.
resolve
(
trackingUrl
);
trackingUrl
=
items
.
splice
(
1
,
items
.
length
).
join
(
''
)
}
}
deferred
.
resolve
(
trackingUrl
);
});
});
this
.
monitorError
(
this
.
pythonShellClient
,
deferred
);
this
.
monitorError
(
this
.
pythonShellClient
,
deferred
);
return
deferred
.
promise
;
return
deferred
.
promise
;
...
@@ -91,12 +89,11 @@ export class AMLClient {
...
@@ -91,12 +89,11 @@ export class AMLClient {
if
(
this
.
pythonShellClient
===
undefined
)
{
if
(
this
.
pythonShellClient
===
undefined
)
{
throw
Error
(
'
python shell client not initialized!
'
);
throw
Error
(
'
python shell client not initialized!
'
);
}
}
let
newStatus
=
oldStatus
;
this
.
pythonShellClient
.
send
(
'
update_status
'
);
this
.
pythonShellClient
.
send
(
'
update_status
'
);
this
.
pythonShellClient
.
on
(
'
message
'
,
function
(
status
:
any
)
{
this
.
pythonShellClient
.
on
(
'
message
'
,
(
status
:
any
)
=>
{
const
items
=
status
.
split
(
'
:
'
);
let
newStatus
=
this
.
parseContent
(
'
status
'
,
status
);
if
(
items
[
0
]
===
'
status
'
)
{
if
(
newStatus
===
'
'
)
{
newStatus
=
items
.
splice
(
1
,
items
.
length
).
join
(
''
)
newStatus
=
oldStatus
;
}
}
deferred
.
resolve
(
newStatus
);
deferred
.
resolve
(
newStatus
);
});
});
...
@@ -117,10 +114,10 @@ export class AMLClient {
...
@@ -117,10 +114,10 @@ export class AMLClient {
throw
Error
(
'
python shell client not initialized!
'
);
throw
Error
(
'
python shell client not initialized!
'
);
}
}
this
.
pythonShellClient
.
send
(
'
receive
'
);
this
.
pythonShellClient
.
send
(
'
receive
'
);
this
.
pythonShellClient
.
on
(
'
message
'
,
function
(
command
:
any
)
{
this
.
pythonShellClient
.
on
(
'
message
'
,
(
command
:
any
)
=>
{
const
items
=
command
.
split
(
'
:
'
)
const
message
=
this
.
parseContent
(
'
receive
'
,
command
);
if
(
items
[
0
]
===
'
receive
'
)
{
if
(
message
!==
'
'
)
{
deferred
.
resolve
(
JSON
.
parse
(
command
.
slice
(
8
)
))
deferred
.
resolve
(
JSON
.
parse
(
message
))
}
}
});
});
this
.
monitorError
(
this
.
pythonShellClient
,
deferred
);
this
.
monitorError
(
this
.
pythonShellClient
,
deferred
);
...
@@ -136,4 +133,13 @@ export class AMLClient {
...
@@ -136,4 +133,13 @@ export class AMLClient {
deferred
.
reject
(
error
);
deferred
.
reject
(
error
);
});
});
}
}
// Parse command content, command format is {head}:{content}
public
parseContent
(
head
:
string
,
command
:
string
):
string
{
const
items
=
command
.
split
(
'
:
'
);
if
(
items
[
0
]
===
head
)
{
return
command
.
slice
(
head
.
length
+
1
);
}
return
''
;
}
}
}
src/nni_manager/training_service/reusable/test/amlClient.test.ts
0 → 100644
View file @
20d5062a
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import
*
as
chai
from
'
chai
'
;
import
{
cleanupUnitTest
,
prepareUnitTest
}
from
'
../../../common/utils
'
;
import
chaiAsPromised
=
require
(
"
chai-as-promised
"
);
import
{
AMLClient
}
from
'
../aml/amlClient
'
;
describe
(
'
Unit Test for amlClient
'
,
()
=>
{
before
(()
=>
{
chai
.
should
();
chai
.
use
(
chaiAsPromised
);
prepareUnitTest
();
});
after
(()
=>
{
cleanupUnitTest
();
});
it
(
'
test parseContent
'
,
async
()
=>
{
let
amlClient
:
AMLClient
=
new
AMLClient
(
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
);
chai
.
assert
.
equal
(
amlClient
.
parseContent
(
'
test
'
,
'
test:1234
'
),
'
1234
'
,
"
The content should be 1234
"
);
chai
.
assert
.
equal
(
amlClient
.
parseContent
(
'
test
'
,
'
abcd:1234
'
),
''
,
"
The content should be null
"
);
});
});
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