You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ejemplo generado por ChatGPT que comprueba si ya existe el entorno para no recrearlo:
# Name of the conda environment
ENV_NAME=myenv
# Conda environment YAML file
ENV_YAML=environment.yml
# Define the rule to create the conda environment if it does not exist
.PHONY: create_env
create_env:
@echo "Checking if conda environment '$(ENV_NAME)' exists..."
@if conda env list | grep -q '$(ENV_NAME)'; then \
echo "Conda environment '$(ENV_NAME)' already exists."; \
else \
echo "Creating conda environment '$(ENV_NAME)'..."; \
conda env create -f $(ENV_YAML); \
fi
# Define the rule to run a command within the conda environment
.PHONY: run
run: create_env
@echo "Running command in conda environment '$(ENV_NAME)'"
conda run -n $(ENV_NAME) python -c "print('Hello from conda environment!')"
# Example of a rule to install dependencies
.PHONY: install
install: create_env
@echo "Installing dependencies in conda environment '$(ENV_NAME)'"
conda run -n $(ENV_NAME) pip install -r requirements.txt
The text was updated successfully, but these errors were encountered:
Esto tiene la ventaja de que la instalación de uv son 2 líneas y se puede hacer de forma desatendida, en conda son más líneas y tienes que interactuar con la terminal.
albertotb
changed the title
Mejorar Makefile
Mejorar Makefile para conda
Sep 17, 2024
Ejemplos:
Ejemplo generado por ChatGPT que comprueba si ya existe el entorno para no recrearlo:
The text was updated successfully, but these errors were encountered: