This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Support saving search space in experiment load&save command #2886
Merged
+44
−2
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
dcd2ffd
Merge pull request #251 from microsoft/master
SparkSnail 3b8b6fb
Merge pull request #252 from microsoft/master
SparkSnail 916e444
Merge pull request #253 from microsoft/master
SparkSnail caeffb8
Merge pull request #254 from microsoft/master
SparkSnail 57c300e
Merge pull request #255 from microsoft/master
SparkSnail 65660e6
Merge pull request #257 from microsoft/master
SparkSnail 9376d6a
Merge pull request #258 from microsoft/master
SparkSnail 5fef3cf
Merge pull request #259 from microsoft/master
SparkSnail 5544ae8
Merge pull request #261 from microsoft/master
SparkSnail f9fdfee
Merge pull request #262 from microsoft/master
SparkSnail c5e26ef
add trial job detail link
SparkSnail 10a04ba
Merge branch 'master' of https://github.com/SparkSnail/nni
SparkSnail aa64fe6
Merge pull request #263 from microsoft/master
SparkSnail 4ed907f
Merge branch 'master' of https://github.com/SparkSnail/nni
SparkSnail c6a5f8c
Merge pull request #264 from microsoft/master
SparkSnail 68abe2f
Merge pull request #265 from microsoft/master
SparkSnail c2b50d2
Merge branch 'master' of https://github.com/SparkSnail/nni
SparkSnail 14e9619
Merge pull request #266 from microsoft/master
SparkSnail f69e206
Merge pull request #267 from microsoft/master
SparkSnail a5bb753
Merge branch 'master' of https://github.com/SparkSnail/nni
SparkSnail 12ef0aa
Merge pull request #270 from microsoft/master
SparkSnail 7600a0f
Merge branch 'master' of https://github.com/SparkSnail/nni
SparkSnail ec61b08
init
SparkSnail 6450fe8
fix pylint
SparkSnail 00d52d9
update doc
SparkSnail a39ccef
fix comments
SparkSnail 7573887
fix comments
SparkSnail 63a9d06
fix comments
SparkSnail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -827,7 +827,18 @@ def save_experiment(args): | |
temp_code_dir = os.path.join(temp_root_dir, 'code') | ||
shutil.copytree(nni_config.get_config('experimentConfig')['trial']['codeDir'], temp_code_dir) | ||
|
||
# Step4. Archive folder | ||
# Step4. Copy searchSpace file | ||
search_space_path = nni_config.get_config('experimentConfig').get('searchSpacePath') | ||
if search_space_path: | ||
if not os.path.exists(search_space_path): | ||
print_warning('search space %s does not exist!' % search_space_path) | ||
else: | ||
temp_search_space_dir = os.path.join(temp_root_dir, 'searchSpace') | ||
os.makedirs(temp_search_space_dir, exist_ok=True) | ||
search_space_name = os.path.basename(search_space_path) | ||
shutil.copyfile(search_space_path, os.path.join(temp_search_space_dir, search_space_name)) | ||
|
||
# Step5. Archive folder | ||
zip_package_name = 'nni_experiment_%s' % args.id | ||
if args.path: | ||
os.makedirs(args.path, exist_ok=True) | ||
|
@@ -844,6 +855,9 @@ def load_experiment(args): | |
if not os.path.exists(args.path): | ||
print_error('file path %s does not exist!' % args.path) | ||
exit(1) | ||
if args.searchSpacePath and os.path.isdir(args.searchSpacePath): | ||
print_error('search space path should be a full path with filename, not a directory!') | ||
exit(1) | ||
temp_root_dir = generate_temp_dir() | ||
shutil.unpack_archive(package_path, temp_root_dir) | ||
print_normal('Loading...') | ||
|
@@ -929,7 +943,32 @@ def load_experiment(args): | |
else: | ||
shutil.copy(src_path, target_path) | ||
|
||
# Step5. Create experiment metadata | ||
# Step5. Copy searchSpace file | ||
archive_search_space_dir = os.path.join(temp_root_dir, 'searchSpace') | ||
if args.searchSpacePath: | ||
target_path = os.path.expanduser(args.searchSpacePath) | ||
else: | ||
# set default path to codeDir | ||
target_path = os.path.join(codeDir, 'search_space.json') | ||
if not os.path.isabs(target_path): | ||
target_path = os.path.join(os.getcwd(), target_path) | ||
print_normal('Expand search space path to %s' % target_path) | ||
nnictl_exp_config['searchSpacePath'] = target_path | ||
# if the path already has a search space file, use the original one, otherwise use archived one | ||
if not os.path.isfile(target_path): | ||
if len(os.listdir(archive_search_space_dir)) == 0: | ||
print_error('Archive file does not contain search space file!') | ||
exit(1) | ||
else: | ||
for file in os.listdir(archive_search_space_dir): | ||
source_path = os.path.join(archive_search_space_dir, file) | ||
os.makedirs(os.path.dirname(target_path), exist_ok=True) | ||
shutil.copyfile(source_path, target_path) | ||
break | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Throw error when no file is found? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is already a judgement in lint 955, don't need to throw error here anymore. |
||
elif not args.searchSpacePath: | ||
print_warning('%s exist, will not load search_space file' % target_path) | ||
|
||
# Step6. Create experiment metadata | ||
nni_config.set_config('experimentConfig', nnictl_exp_config) | ||
experiment_config.add_experiment(experiment_id, | ||
experiment_metadata.get('port'), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a dir?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For storage data and classify. There are a few folders in archive folder, including 'code', 'nnictl', 'experiment', 'searchSpace', the search space file's name is random, put this file into 'searchSpace' folder for identify.