Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

fix experiment import bug and add it cases: experiment import #2878

Merged
merged 4 commits into from
Sep 21, 2020

Conversation

J-shang
Copy link
Contributor

@J-shang J-shang commented Sep 9, 2020

In docs, experiment import data format example below, value can be set as float, but json_tricks.loads() only accept string, so fix it.

[
  {"parameter": {"x": 0.5, "y": 0.9}, "value": 0.03},
  {"parameter": {"x": 0.4, "y": 0.8}, "value": 0.05},
  {"parameter": {"x": 0.3, "y": 0.7}, "value": 0.04}
]

Add IT cases about experiment import and export.

@@ -114,7 +114,7 @@ def handle_import_data(self, data):
data: a list of dictionaries, each of which has at least two keys, 'parameter' and 'value'
"""
for entry in data:
entry['value'] = json_tricks.loads(entry['value'])
entry['value'] = json_tricks.loads(str(entry['value']))
Copy link
Contributor

@QuanluZhang QuanluZhang Sep 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the type of entry['value']? a dict/list object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this simple case like [{"parameter": {...}, "value": 0.03}], it is <class 'float'>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is float, why we invoke json_tricks.loads?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe in some complex scene, user will set value as other types? like numpy array? This should invoke json_tricks.loads to converted back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think entry['value'] should be a string, otherwise, there is a bug somewhere else.

@@ -0,0 +1,4 @@
[
{"parameter": {"C": 0.15940134774738896, "kernel": "sigmoid", "degree": 3, "gamma": 0.07295826917955316, "coef0 ": 0.0978204758732429}, "value": 0.6},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"coef0 "?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in search_space.json is "coef0 ", should I modify them all?

"coef0 ": {"_type":"uniform","_value":[0.01, 0.1]}

@scarlett2018 scarlett2018 mentioned this pull request Sep 11, 2020
79 tasks
configFile: test/config/nnictl_experiment/sklearn-classification.yml
launchCommand: nnictl resume $imoprtExpId
stopCommand: nnictl experiment export --filename config/nnictl_experiment/test_export.json --type json --intermediate
onExitCommand: nnictl stop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the proper way to use stopCommand and onExitCommand.
Here the result of nnictl experiment export should be checked, you can use a validator to run export command and validate the results.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to modify them and add a validator.

@J-shang J-shang changed the title fix experiment import bug and add it cases: experiment import & export fix experiment import bug and add it cases: experiment import Sep 16, 2020
import_data_file_path = kwargs.get('import_data_file_path')
proc = subprocess.run(['nnictl', 'experiment', 'import', exp_id, '-f', import_data_file_path])
assert proc.returncode == 0, \
'`nnictl experiment import {0} -f {1}` failed with code {2}'.format(exp_id, import_data_file_path, proc.returncode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any other means to verify the data is actually imported successfully besides checking the return code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll view the code again to find if there is a way to check the result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to check the imported data, add an api api/v1/nni/experiment/imported-data to get the imported data. I don't know if it is appropriate to do so. Maybe users also have demand to view the data they have imported?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is OK to call api/v1/nni/experiment/imported-data to verify

@chicm-ms
Copy link
Contributor

@SparkSnail Please help review nni_cmd/updater.py

@chicm-ms chicm-ms merged commit a480208 into microsoft:master Sep 21, 2020
@J-shang J-shang deleted the fix-import branch October 19, 2020 02:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants