This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
environment variable handling in unittests #18424
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ee62440
Add 'with environment(<env var dict>):' wrapper
DickJC123 b650604
Expand use of 'with environment():'. Add @with_environment() unittes…
DickJC123 85310b3
Validate env var setting in backend via wrapped {get,set}env
DickJC123 d1b2d01
Fix cpplint
DickJC123 946b668
Fix pylint
DickJC123 2a13c83
Fix test_base.py:test_data_dir
DickJC123 aa6ba7f
Enable env-var-setting unittests on Windows
DickJC123 a2ca625
Add tests
DickJC123 765444a
Fix pylint
DickJC123 8f71a7e
Merge remote-tracking branch 'mxnet/master' into environ_pr
DickJC123 76c13b1
Remove files corresponding to lost symlinks
DickJC123 7656742
Readd macos->linux and windows->linux symlinks under docs
DickJC123 8ad3b79
unittest/nosetest refs mapped to pytest
DickJC123 3e79f40
Fix invalid python function refs
DickJC123 460dd21
simple_bind -> _simple_bind
DickJC123 29286c3
Fix flakiness of test_gluon_probability{_v1,_v2}.py::test_cauchy{_v1,}
DickJC123 2c4b1f5
Convert recently added tests to use 'with environment()'
DickJC123 3fd1ab4
run_in_spawned_process() to use 'with environment()'
DickJC123 69a39c3
Make more clear on-error seed warning message
DickJC123 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
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 |
---|---|---|
|
@@ -106,3 +106,25 @@ int MXRemoveSubgraphPropertyOpNamesV2(const char* prop_name) { | |
} | ||
API_END(); | ||
} | ||
|
||
int MXGetEnv(const char* name, | ||
const char** value) { | ||
API_BEGIN(); | ||
*value = getenv(name); | ||
API_END(); | ||
} | ||
|
||
int MXSetEnv(const char* name, | ||
const char* value) { | ||
API_BEGIN(); | ||
#ifdef _WIN32 | ||
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. Would it be a good idea to put a mutex? setenv is not thread safe. 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. The sequence we follow of checkpoint_env_vars, change_env_vars, run_test, reinstate_env_vars, is fundamentally not thread-safe. I'm not making those guarantees, so no mutex is required I feel. |
||
auto value_arg = (value == nullptr) ? "" : value; | ||
_putenv_s(name, value_arg); | ||
#else | ||
if (value == nullptr) | ||
unsetenv(name); | ||
else | ||
setenv(name, value, 1); | ||
#endif | ||
API_END(); | ||
} |
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
Oops, something went wrong.
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.
👍 That difference can be nasty.