vsoch / scif

scientific filesystem: a filesystem organization for scientific software and metadata
https://sci-f.github.io/
Mozilla Public License 2.0
30 stars 12 forks source link

Support app names containing period (".") #35

Closed Saford91 closed 6 years ago

Saford91 commented 6 years ago

Similar to https://github.com/singularityware/singularity/issues/1237, SCIF app names with periods will try to create environment variables with invalid names.

vsoch commented 6 years ago

oups you beat me to it, haha. I'm on this!

vsoch commented 6 years ago

hey @Saford91 do you have a recipe (currently in Singularity) I could use to create you an example? I'm guessing you are using native singularity, and I'd like to show you how to build the same Singularity container with the SCIF client so that if there are bugs / changes needed, we don't need to wait for PR to Singularity to get the issue fixed.

Saford91 commented 6 years ago

Thank you for tackling this so soon. Unfortunately, I don't have any real recipes that use this. The recipe where I first encountered it is still a WIP. I created this test recipe that demonstrates the problem:

bootstrap: docker
from: centos

%appenv FOO.BAR
  FOO=BAR
  export FOO

%apprun FOO.BAR
  echo $FOO

%runscript
  echo "FOOBAR"

# singularity run --app FOO.BAR  test
/.singularity.d/env/94-appsbase.sh: line 1: APPDATA_FOO.BAR=/scif/data/FOO.BAR: No such file or directory
/.singularity.d/env/94-appsbase.sh: line 2: APPMETA_FOO.BAR=/scif/apps/FOO.BAR/scif: No such file or directory
/.singularity.d/env/94-appsbase.sh: line 3: APPROOT_FOO.BAR=/scif/apps/FOO.BAR: No such file or directory
/.singularity.d/env/94-appsbase.sh: line 4: APPBIN_FOO.BAR=/scif/apps/FOO.BAR/bin: No such file or directory
/.singularity.d/env/94-appsbase.sh: line 5: APPLIB_FOO.BAR=/scif/apps/FOO.BAR/lib: No such file or directory
/.singularity.d/env/94-appsbase.sh: line 6: export: `APPDATA_FOO.BAR': not a valid identifier
/.singularity.d/env/94-appsbase.sh: line 6: export: `APPROOT_FOO.BAR': not a valid identifier
/.singularity.d/env/94-appsbase.sh: line 6: export: `APPMETA_FOO.BAR': not a valid identifier
/.singularity.d/env/94-appsbase.sh: line 6: export: `APPBIN_FOO.BAR': not a valid identifier
/.singularity.d/env/94-appsbase.sh: line 6: export: `APPLIB_FOO.BAR': not a valid identifier
/.singularity.d/env/94-appsbase.sh: line 7: APPENV_FOO.BAR=/scif/apps/FOO.BAR/scif/env/90-environment.sh: No such file or directory
/.singularity.d/env/94-appsbase.sh: line 8: export: `APPENV_FOO.BAR': not a valid identifier
/.singularity.d/env/94-appsbase.sh: line 9: APPLABELS_FOO.BAR=/scif/apps/FOO.BAR/scif/labels.json: No such file or directory
/.singularity.d/env/94-appsbase.sh: line 10: export: `APPLABELS_FOO.BAR': not a valid identifier
/.singularity.d/env/94-appsbase.sh: line 11: APPRUN_FOO.BAR=/scif/apps/FOO.BAR/scif/runscript: No such file or directory
/.singularity.d/env/94-appsbase.sh: line 12: export: `APPRUN_FOO.BAR': not a valid identifier
BAR
vsoch commented 6 years ago

yuck! Okay here a PR to fix this up:

https://github.com/vsoch/scif/pull/37

And I've written a little build recipe (from your inspiration) to help test it. Call this recipe.scif

%appenv FOO.BAR
  FOO=BAR
  export FOO
%apprun FOO.BAR
  echo $FOO
%appenv name.v3.0
    THEBESTAPP="name.v3.0"
    export THEBESTAPP
%appenv name.v2.0
    THEBESTAPP="name.v2.0"
    export THEBESTAPP
%appenv name.v1.0
    THEBESTAPP="name.v1.0"
    export THEBESTAPP
%apprun name.v1.0
    echo "The best app is $THEBESTAPP"
%apphelp name.v1.0
    This is an example application that has periods in the name. You can install
    it to a host via:

       pip install scif
       scif install recipe.scif

and ironically I can't test in Singularity because of the same bug, so before fixing there I'll show you how to use it here with a Docker recipe:

#########################################
# docker build -t vanessa/scif-base .
# docker run vanessa/scif-base
#########################################

FROM continuumio/miniconda3

ADD . /
RUN /opt/conda/bin/pip install scif
RUN scif install /recipe.scif
ENTRYPOINT ["scif"]

building is at the top, and then usage:

# this will show the scif entrypoint
docker run vanessa/scif-base

# what apps are installed?
docker run vanessa/scif-base apps
 name.v2.0
 name.v3.0
   FOO.BAR
 name.v1.0

# Run FOO.BAR
docker run vanessa/scif-base run FOO.BAR
[FOO.BAR] executing /bin/bash /scif/apps/FOO.BAR/scif/runscript
BAR

Once the fix is done in Singularity, the same singularity recipe can be used, the only difference is how you add the files and then define entrypoints, etc.

BootStrap: docker
From: continuumio/miniconda3

# sudo singularity build versions.simg Singularity

%files
    recipe.scif

%runscript
    exec /opt/conda/bin/scif "$@"

%post
    apt-get update
    /opt/conda/bin/pip install scif
    /opt/conda/bin/scif install /recipe.scif
vsoch commented 6 years ago

Going to close this here!