Coder Social home page Coder Social logo

tillbaar / summon-conda-envs Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 14 KB

Bash script to quickly archive and restore conda environments from YAML files.

Shell 100.00%
bash bash-script bash-scripting conda conda-environment conda-env yaml yaml-files python inode inodes

summon-conda-envs's Introduction

summon-conda-envs

While working with Python on a compute cluster I ran into the following problem:

  • Python (or at least the version I needed) wasn't available by default.
  • This is why I opted for a local conda environment. This would also allow me to manage different Python and module versions for my various projects.
  • While this worked out initially, conda environments are not only somehwhat big, they also contain a lot of files, quickly using up my allotted inode quota.
  • Luckily, conda environments (or at least the specifications of any given environment) can be archived to a single YAML file and later restored from that file.

I therefor wrote the a tiny bash script that takes care of archiving and restoring conda environments to and from YAML files for me so I don't have to worry about the details.

Usage

It works as follows:

Usage: condaenv summon [-l] env    restore a conda environment from a yml file
   or: condaenv unsummon    env    archive a conda environment as a yml file
   or: condaenv -h                 display extended help message

    summon    Searches for a YAML file in a specified directory and uses it to
              create a conda environment.
  
  unsummon    Searches for a conda environment and stores it as a YAML file in
              a specified directoy. The stored environment is removed.

Arguments:
  -l  local   Without this option, all new conda enviroments are created in a
              specified directory of the user's choice. If this option is set
              the new conda environment is created in the standard path for
              conda environments instead.
 
  -h  help    Displays this extended help message.

Examples

So, let's assume you have created a conda environment called foo that you don't need at the moment.

To archive the environment to a YAML file you would use:

condaenv unsummon foo

The environment will be archived to foo.yml in a directory specified at the beginning of the script.

To restore the environment from that YAML file you would use:

condaenv summon foo

The environment will be restored from foo.yml to a directory specified at the beginning of the script.

Alternatively, you can use:

condaenv summon -l foo

This will restore the environment to the standard directory for conda environments on you system.

Things to consider

You need to set two paths at the beginning of the script.

  • ENV_DIR is the directory where conda environments should be created if the -l option is not given.
  • YML_DIR is the directoy where YAML files are stored.

Additionally, to call the script simply by typing condaenv, you need to provide an alias in your .bashrc

summon-conda-envs's People

Contributors

tillbaar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.