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

rename preCommand to pythonPath #3410

Merged
merged 8 commits into from
Mar 5, 2021

Conversation

acured
Copy link
Contributor

@acured acured commented Mar 2, 2021

No description provided.

@@ -110,7 +110,7 @@ Training service
""""""""""""""""


* Support configuring python environment using "preCommand" in remote mode (#2875)
* Support configuring python environment using "pythonPath" in remote mode (#2875)
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 the release doc of v1.9, please revert it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

@@ -105,7 +105,7 @@ def _handle_training_service(ts, data):
'gpuIndices': _convert_gpu_indices(machine.get('gpuIndices')),
'maxTrialNumPerGpu': machine.get('maxTrialNumPerGpu'),
'useActiveGpu': machine.get('useActiveGpu'),
'preCommand': machine.get('trialPrepareCommand')
'pythonPath': machine.get('trialPrepareCommand')
Copy link
Contributor

Choose a reason for hiding this comment

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

trialPrepareCommand -> trialPythonPath
trial_prepare_command -> trial_python_path

also in other files, like experiment_config.rst.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@J-shang J-shang requested a review from QuanluZhang March 3, 2021 01:29
@@ -538,7 +538,7 @@ If `trialGpuNumber`_ is less than the length of this value, only a subset will b
This will be used as ``CUDA_VISIBLE_DEVICES`` environment variable.


trialPrepareCommand
trialPythonPath
-------------------

Command(s) to run before launching each trial.
Copy link
Contributor

Choose a reason for hiding this comment

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

The path will insert to PATH before launching each trial.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -538,10 +538,10 @@ If `trialGpuNumber`_ is less than the length of this value, only a subset will b
This will be used as ``CUDA_VISIBLE_DEVICES`` environment variable.


trialPrepareCommand
trialPythonPath
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the difference between pythonPath and trialPythonPath?

Copy link
Contributor

Choose a reason for hiding this comment

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

pythonPath is config v1
trialPythonPath is config v2

Copy link
Contributor

Choose a reason for hiding this comment

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

why use different names?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just follow the previous naming way: preCommand is config v1, trialPrepareCommand is config v2. Or use pythonPath is enough? @liuzhe-lz

Copy link
Contributor

@liuzhe-lz liuzhe-lz Mar 3, 2021

Choose a reason for hiding this comment

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

I think pythonPath is enough.
It was named trialPrepareCommand because the command executes once per trial. preCommand made me guess it would execute once per machine.

Copy link
Contributor

Choose a reason for hiding this comment

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

could someone explain when to use pythonPath and when trialPythonPath should be used?

@QuanluZhang QuanluZhang requested a review from SparkSnail March 3, 2021 05:54
@@ -144,7 +144,7 @@ Files in ``codeDir`` will be uploaded to remote machines automatically. You can
Configure python environment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

By default, commands and scripts will be executed in the default environment in remote machine. If there are multiple python virtual environments in your remote machine, and you want to run experiments in a specific environment, then use **preCommand** to specify a python environment on your remote machine.
By default, commands and scripts will be executed in the default environment in remote machine. If there are multiple python virtual environments in your remote machine, and you want to run experiments in a specific environment, then use **pythonPath** to specify a python path environment on your remote machine.
Copy link
Contributor

Choose a reason for hiding this comment

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

python path evnironment seems strange, python environment is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

# preCommand: source ${replace_to_absolute_path_recommended_here}/bin/activate
# preCommand: source ${replace_to_conda_path}/bin/activate ${replace_to_conda_env_name}
preCommand: export PATH=${replace_to_python_environment_path_in_your_remote_machine}:$PATH
pythonPath: ${replace_to_python_environment_path_in_your_remote_machine}
Copy link
Contributor

Choose a reason for hiding this comment

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

better to add comments to show concrete path examples here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

The doc said "The path will insert to PATH before launching each trial". Is /usr/bin/python3.7 supposed to be a directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a directory, "python3.7" is a folder name..I will rename it to "yourPythonPath" to avoid the misunderstanding.

Copy link
Contributor

@liuzhe-lz liuzhe-lz Mar 3, 2021

Choose a reason for hiding this comment

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

Then I suggest /opt/python3.7/bin for Linux example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@QuanluZhang
Copy link
Contributor

@acured , how to set pythonPath when using natively installed python, anaconda, and python virtual env?

@acured
Copy link
Contributor Author

acured commented Mar 3, 2021

@acured , how to set pythonPath when using natively installed python, anaconda, and python virtual env?

Set the natively python path(located) directly.

@SparkSnail
Copy link
Contributor

SparkSnail commented Mar 3, 2021

@acured , how to set pythonPath when using natively installed python, anaconda, and python virtual env?

Set the natively python path(located) directly.

did you tested using export PATH=${pythonPath}:$PATH && ${command} works for both anaconda and python virtual env? In previous, seems it use source ${replace_to_absolute_path_recommended_here}/bin/activate to activate python.

@acured
Copy link
Contributor Author

acured commented Mar 3, 2021

@acured , how to set pythonPath when using natively installed python, anaconda, and python virtual env?

Set the natively python path(located) directly.

did you tested using export PATH=${pythonPath}:$PATH && ${command} works for both anaconda and python virtual env? In previous, seems it use source ${replace_to_absolute_path_recommended_here}/bin/activate to activate python.

For "pip install" I am going to test, for "python" it is working fine.

-------------------

Command(s) to run before launching each trial.
The path will insert to PATH before launching each trial.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make it clear whether it's inserted at front or at tail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@acured
Copy link
Contributor Author

acured commented Mar 3, 2021

@acured , how to set pythonPath when using natively installed python, anaconda, and python virtual env?

Set the natively python path(located) directly.

did you tested using export PATH=${pythonPath}:$PATH && ${command} works for both anaconda and python virtual env? In previous, seems it use source ${replace_to_absolute_path_recommended_here}/bin/activate to activate python.

For "pip install" I am going to test, for "python" it is working fine.

After a test, It will cause an issue when working on windows anaconda if only set the native python path without active the env. To fix this issue, user have to set other two path: "../script" and "../Library/bin", I already add it in config_remote.yml in this PR.

There is no issue on linux.

@J-shang J-shang closed this Mar 3, 2021
@J-shang J-shang reopened this Mar 3, 2021
-------------------

Command(s) to run before launching each trial.
The path will insert at the front of PATH.
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest to add detailed description here, for example, what is this field used for? how to set the path for different python environments and OS, add examples like the ones you wrote in the example yaml file below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -144,7 +144,7 @@ Files in ``codeDir`` will be uploaded to remote machines automatically. You can
Configure python environment
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

By default, commands and scripts will be executed in the default environment in remote machine. If there are multiple python virtual environments in your remote machine, and you want to run experiments in a specific environment, then use **preCommand** to specify a python environment on your remote machine.
By default, commands and scripts will be executed in the default environment in remote machine. If there are multiple python virtual environments in your remote machine, and you want to run experiments in a specific environment, then use **pythonPath** to specify a python environment on your remote machine.
Copy link
Contributor

Choose a reason for hiding this comment

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

How does it work? If I execute a command line tool that uses python, for example, nnictl, lightgbm, horovodrun, will it work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When you set this pythonPath, it will be added to the front of env PATH in current terminal, which means when you run any tool that calls python or run python directly from the terminal, this python your provided the path will be chosen first.
But it only works for current terminal which your set the pythonPath at first.

@J-shang J-shang closed this Mar 5, 2021
@J-shang J-shang reopened this Mar 5, 2021
@J-shang J-shang merged commit f897829 into microsoft:master Mar 5, 2021
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