[go: nahoru, domu]

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

Revamp env kwarg in new implementation and provide pre launch logic #39

Open
jaimergp opened this issue Oct 20, 2022 · 1 comment · May be fixed by #40
Open

Revamp env kwarg in new implementation and provide pre launch logic #39

jaimergp opened this issue Oct 20, 2022 · 1 comment · May be fixed by #40

Comments

@jaimergp
Copy link
Member

We forgot about the env keyword argument in #31, oopsie.

This keyword allows users to inject environment variables in the kernel launch. We used it for LD_LIBRARY_PATH, but we don't need that anymore because we activate the environment fully.

Instead, I suggest we revamp this option and mix it with a new keyword argument `pre_kernel_launch or something. It should accept either a path to a file or a multiline content str.

Logic would be like:

def fn(..., env={"my_var": "my_value"}, pre_kernel_launch="my_script.sh"):
  ...
  contents = ""
  for key, value in env.items():
    contents += f'export {key}="{value}"\n'
  with open(pre_kernel_launch_script) as f:
    contents += "\n"
    contents += f.read()
  ...
  with open(sys.executable, "w") as f:
    f.write(
      f"""
      #!/bin/bash
      {contents}  # this is the new change!
      source {prefix}/etc/profile.d/conda.sh
      conda activate
      unset PYTHONPATH
      mv /usr/bin/lsb_release /usr/bin/lsb_release.renamed_by_condacolab.bak
      exec {bin_path}/python $@
      """
@jaimergp
Copy link
Member Author

cc @ssurbhi560

@ssurbhi560 ssurbhi560 linked a pull request Oct 27, 2022 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant