Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not export unnecessary conda env vars, use conda run #232

Merged
merged 10 commits into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions mesmerize_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,7 @@ def make_runfile(

f.write(f"#!/bin/bash\n")

if "CONDA_PREFIX" in os.environ.keys():
f.write(
f'export CONDA_PREFIX={os.environ["CONDA_PREFIX"]}\n'
f'export CONDA_PYTHON_EXE={os.environ["CONDA_PYTHON_EXE"]}\n'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure this is no longer necessary?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean the CONDA_PYTHON_EXE

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 believe these env variables will not do anything if the conda environment is not activated and you call the default python below.

f'export CONDA_PREFIX_1={os.environ["CONDA_PREFIX_1"]}\n'
)

elif "VIRTUAL_ENV" in os.environ.keys():
if "VIRTUAL_ENV" in os.environ.keys():
f.write(
f'export PATH={os.environ["PATH"]}\n'
f'export VIRTUAL_ENV={os.environ["VIRTUAL_ENV"]}\n'
Expand All @@ -132,9 +125,17 @@ def make_runfile(
f'export MESMERIZE_N_PROCESSES={os.environ["MESMERIZE_N_PROCESSES"]}\n'
)

f.write(f"export OPENBLAS_NUM_THREADS=1\n" f"export MKL_NUM_THREADS=1\n")
f.write(
f"export OPENBLAS_NUM_THREADS=1\n"
f"export MKL_NUM_THREADS=1\n"
)

f.write(f"python {module_path} {args_str}") # call the script to run
if "CONDA_PREFIX" in os.environ.keys():
# add command to run the python script in the conda environment
# that was active at the time that this shell script was generated
f.write(f'{os.environ["CONDA_EXE"]} run -p {os.environ["CONDA_PREFIX"]} python {module_path} {args_str}')
else:
f.write(f"python {module_path} {args_str}") # call the script to run

else:
with open(sh_file, "w") as f:
Expand All @@ -155,6 +156,8 @@ def make_runfile(
st = os.stat(sh_file)
os.chmod(sh_file, st.st_mode | S_IEXEC)

print(sh_file)

return sh_file


Expand Down
Loading