Giter Club home page Giter Club logo

condimentstation's Introduction

A propos

CondimenStation is a salt-derived environment to maintain and share state on personal laptops in an ad-hoc way. It enables users to setup their laptops and dotfiles. It enables teams to setup separate programming environment for each project and share them. The goal is to limit the amount of pain when joining a project, while maintaining complete freedom for each user to do whatever she cares.

Basically, it's github's boxen but chaotic good. With salt rather than puppet, YAML rather than a homegrown DSL, and python rather than ruby.

Installation

  1. Create a directory to hold stuff

  2. Inside this main directory clone CondimentStation to subdirectory CondimentStation

  3. Fork mdavezac/template_black-garlic and rename your fork to black-garlic

  4. Clone your black-garlic to a subdirectory black-garlic inside the main directory

  5. Edit the files in pillar/black-garlic to fit your preferences

  6. From the main directory, run CondimentStation/bootstrap.sh

  7. Setup your environment to use spack. My zprofile has:

    export SPACK_ROOT=<spack root>
    source $SPACK_ROOT/share/spack/setup-env.sh
    
    [[ -e /usr/local/Cellar/lmod/5.9.3/init/zsh ]] && \
      source /usr/local/Cellar/lmod/5.9.3/init/zsh
    module use $HOME/.funwith

    Where by default <spack_root> is /path/to/main/directory/from/this/readme/build/spack or whatever you've decided on in the pillar black-garlic/pillar/spack.sls

Usage

Once installed, you should be able to do:

module load condiment_station

This will setup your environment so you can run states. The states are the .sls files found directly in:

  • main_directory/black-garlic
  • main_directory/CondimentStation
  • main_directory/black-garlic/projects
  • main_directory/

Starting with the top-most and falling back to the ones below if a state is not found.

A state can be called with:

pinch.py run CondimentStation.projects.condiment_station

This will run the state file CondimentStation/projects/condiment_station.sls. Thanks to the fall-back mechanism, we could also just run it with pinch.py projects.condiment_station assuming no such file exist in black-garlic.

Any state accessible from black-garlic/top.sls will run when pinch.py run is called without argument.

pinch.py can also run arbitrary salt modules:

pinch.py call pillar.items

Or show an state file before running it

pinch.py show black-garlic

That particular state is a staple from the black-garlic template. It simply inherits from the state in CondimentStation/projects/condiment_station. Do look inside black-garlic/projects/black-garlic.sls to figure out add your own stuff to somebody-elses project.

Adding other peoples projects

The pillar black-garlic/pillar/condiments make it easy to add other peoples dotfiles/projects and include them in your own.

Assuming it contains:

condiments:
   chilly-oil:
       github: mdavezac/black-garlic

Then running:

pinch.py run condiments

Will download mdavezac's black-garlic into the chilly-oil subdirectory of the main directory. From there, it can be used directly by running pinch.py run chilly-oil.some_state or by including states in your own black-garlic.

Exemplar project file

{% set compiler = salt["spack.compiler"]() %}
{% set python = salt['pillar.get']('python', 'python3') %}
{% set mpilib = salt['pillar.get']('mpi', 'openmpi') %}
{% set project = sls.split('.')[-1] %}
{% set workspace = salt['funwith.workspace'](project) %}

{{project}} spack packages:
  spack.installed:
    - pkgs: &spack_packages
      - GreatCMakeCookoff
      - eigen %{{compiler}} -fftw -scotch -metis -suitesparse
      - swig %{{compiler}}

{{workspace}}/{{python}}:
  virtualenv.managed:
    - python: {{python}}
    - pip_upgrade: True
    - use_wheel: True
    - pip_pkgs: [pip, numpy, scipy, pytest, pandas, cython, behave]

DCPROGS/HJCFIT:
  github.latest:
    - target: {{workspace}}/src/{{project}}

dcprogs:
  funwith.modulefile:
    - spack: *spack_packages
    - virtualenv: {{workspace}}/{{python}}
{% if compiler == "gcc" %}
    - footer: |
        setenv("CXX", "g++-6")
        setenv("CC", "gcc-6")
{% endif %}

There are few variables of interest here:

  • compiler: specifies the spack compiler collection to use. It can be modified from the command-line with pinch.py run --compiler clang
  • python: either python2 or python3 and can also be modified from the command-line.
  • project: the name of the current sls file, for convenience
  • workspace: a project-specific location where the projects can go.

Running the file above will create a virtualenv in the specific workspace directory, add some spack packages, download the sources for the program of interest, and add a module file to setup the enviroment.

After running this particular project, it should be possible to do:

module load dcprogs

And the dcprogs environment will be setup so the right spack libraries are found, the virtualenv is activated, etc...

Configuration

All configuration should happen in files in the pillar subdirectory of your black-garlic. These file need to be included in black-garlic/pillar/top.sls for salt to register them.

black-garlic/pillar/secrets.sls: Never commited to version control. This is where secrets should go.

workspaces: A directory where all project workspaces will go.

modulefiles: A directory where all project module files will go. This directory should be loaded by lmod, module use <directory>, somewhere in your .bash_profile.

spack:compilers_file: Points to a file defining spack-compilers. See spack itself for a description. Optional.

spack:external_packages: Points to a file defining the equivalent of spack-packages installed some other way (brew?). See spack for description.

spack:directory: Where the main spack repo will go

spack:repo_prefix: Where subsidiary repos of spack-packages are installed.

spack:repos: Dictionary with subsidiary spack repos.

The following configuration is generated by CondimentStation/bin/bootstrap.sh into black-garlic/pillar/salt.sls and should not be messed with:

user: User using condiment station

condiment_prefix: Main directory for condiment station

condiment_dir: Directory containing CondimentStation itself

condiment_python: Executable with to the python executable for the virtualenv used by condiment station

condiment_build_dir: Directory with most files generated by CondimentStation. This directory can be removed and then regenerated with CondimentStation/bin/bootstrap.sh

condimentstation's People

Contributors

jenshnielsen avatar mdavezac avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

ucl-rits dpshelio

condimentstation's Issues

Fail to install spack modules

Some just fail in the install after the install phase (maybe updating spack database?)

==> Installing GreatCMakeCookoff
==> Using cached archive: /home/dvd/Stuff/build/spack/var/spack/cache/GreatCMakeCookoff/GreatCMakeCookoff-2.1.9.tar.gz
==> Already staged GreatCMakeCookoff-2.1.9-jzrvdssgv3u7j3y4clwfihd26vhh5d3y in /home/dvd/Stuff/build/spack/var/spack/stage/GreatCMakeCookoff-2.1.9-jzrvdssgv3u7j3y4clwfihd26vhh5d3y
==> No patches needed for GreatCMakeCookoff
==> Building GreatCMakeCookoff [Package]
==> Executing phase: 'install'
==> Error: TypeError: can't pickle _yaml.Mark objects
TypeError: TypeError: can't pickle _yaml.Mark objects

/home/dvd/Stuff/build/spack/lib/spack/spack/package.py:1456, in build_process:
     60                        self.log()
     61    
     62                    # Run post install hooks before build stage is removed.
  >> 63                    spack.hooks.post_install(self.spec)
     64    
     65                # Stop timer.
     66                self._total_time = time.time() - start_time

whereas in other cases creates flags that spack doesn't know:

[email protected]%[email protected]~cuda fabrics= ~java schedulers= ~sqlite3~thread_multiple~ucx+vt arch=linux-archrolling-x86_64
^[email protected]%[email protected]~cuda+libxml2+pci+shared arch=linux-archrolling-x86_64
^[email protected]%[email protected] arch=linux-archrolling-x86_64
^[email protected]%[email protected] arch=linux-archrolling-x86_64
^[email protected]%[email protected] arch=linux-archrolling-x86_64
^[email protected]%[email protected]~python arch=linux-archrolling-x86_64
^[email protected]%[email protected] patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00
+sigsegv arch=linux-archrolling-x86_64 ^[email protected]%[email protected] arch=linux-archrolling-x86_64 
^[email protected]%[email protected] arch=linux-archrolling-x86_64 
^[email protected]%[email protected] arch=linux-archrolling-x86_64
^[email protected]%[email protected]+optimize+pic+shared arch=linux-archrolling-x86_64

like fabrics= ~java and schedulers= ~sqlite3...

salt-pip packages are not installed on the first run

When run the first time the following error is shown:

pip_|-salt packages_|-salt packages_|-installed:
    ----------
    __run_num__:
        0
    changes:
        ----------
    comment:
        State 'pip.installed' was not found in SLS 'salt'
        Reason: 'pip.installed' is not available.
    name:
        salt packages
    result:
        False
...
Some salt state failed

If run again after this, then installs jupyter that's the only package missing in salt.sls that's not in the bootstrap:

pip_|-salt packages_|-salt packages_|-installed:
    ----------
    jupyter==1.0.0:
        Installed

Maybe the saltutil.sync_all command in https://github.com/mdavezac/CondimentStation/blob/master/bin/pinch.py#L113 set before applying salt.sls is not working as expected.
This issue seems similar to what's explained in the documentation about reloading-modules. But I've tried to add such reload_modules: true at different places in condiment_scripts.sls and not luck.

For example I've tried adding:

python-pip:
  cmd.run:
    - name: |
        [[ -e {{salt['pillar.get']('condiment_build_dir')}}/salt-env/bin/pip ]]
    - cwd: /
    - reload_modules: true

~/.salted doesn't get created

when spack state is applied at first, if add_to_zprofile is set to true, it tries to add a file into ~/.salted/ however that directory may not exist.

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.