How to access predefined environment variables in conda environment.yml?

2024/11/15 22:59:36

I wish to share an environment.yml file for others to reproduce the same setup as I have. The code we use depends on the environment variable $PWD. I wish to set a new env variable in the environment.yml where I can access $PWD.

for eg. I am able to do:

variables:VAR1: something

but can't do

variables:VAR1: $PWD/solution

where $PWD is set based on where the user has cloned the repo.

Also, how do I update predefined environment variables such as $PYTHONPATH?

variables:PYTHONPATH: $PWD:$PYTHONPATH

doesn't work similarly.

Answer

I faced similar issue while accessing gitlab variables within environment.yml. I didnt find any solution on internet and finally i had to follow below in my gitlab-ci.yml's script section:

  • create conda environment using yml file
  • activate environment
  • create variables using conda env config vars set VAR=value
  • deactivate environment
  • activate environment
https://en.xdnf.cn/q/71839.html

Related Q&A

Python enclosing scope variables with lambda function

I wrote this simple code:def makelist():L = []for i in range(5):L.append(lambda x: i**x)return Lok, now I callmylist = makelist()because the enclosing scope variable is looked up when the nested functi…

Overloading + to support tuples

Id like to be able to write something like this in python:a = (1, 2) b = (3, 4) c = a + b # c would be (4, 6) d = 3 * b # d would be (9, 12)I realize that you can overload operators to work with custom…

Extracting particular text associated value from an image

I have an image, and from the image I want to extract key and value pair details.As an example, I want to extract the value of "MASTER-AIRWAYBILL NO:" I have written to extract the entire te…

Installing pip in Pycharm 2016.3

I upgraded to the new version of Pycharm. In the terminal, it says bash-3.2$ instead of my username. When I tried to install a library, it said that pip command is not found:bash: pip: command not foun…

How to store real-time chat messages in database?

I am using mysqldb for my database currently, and I need to integrate a messaging feature that is in real-time. The chat demo that Tornado provides does not implement a database, (whereas the blog does…

Selectively import from another Jupyter Notebook

I arranged my Jupyter notebooks into: data.ipynb, methods.ipynb and results.ipynb. How can I selectively import cells from data and methods notebooks for use in the results notebook?I know of nbimport…

supervisord event listener

Im trying to configure an event listener for supervisord but cant get it to work. I just want to listen for PROCESS_STATE changes and run some python code triggering an urllib2request.In my .conf I hav…

Integration of Java and Python Code in One Eclipse Project

I am writing a compiler in Python using Eclipse with PyDev. Ive come to a stage where I needed to write some code in Java. Im wandering if there is a way of combining these into a single project, bec…

formatting of timestamp on x-axis

Im trying to format the x-axis in my weather data plot. Im happy with the y-axis but all my tries to get the x-axis into a decent, human-readable format didnt work so far. So after several hours of tri…

How can I set the row height in Tkinter TreeView?

I wrote a small app recently that needs to be cross-platform. I used Python and Tkinter for the GUI.It works great but recently I got a new laptop with a hiDPI screen and it seems to mess up the TreeVi…