From f37994520e3f2bf23c6cc36a0b1dd1f5d0533132 Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Wed, 11 Dec 2019 14:30:39 +0100 Subject: [PATCH 1/5] Skeleton, and added requirements that will be used. --- pyhdtoolkit/beamphysics/__init__.py | 0 requirements.txt | 4 +++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 pyhdtoolkit/beamphysics/__init__.py diff --git a/pyhdtoolkit/beamphysics/__init__.py b/pyhdtoolkit/beamphysics/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/requirements.txt b/requirements.txt index 8248f97b..bbb722fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ matplotlib -numpy \ No newline at end of file +numpy +pandas +scipy \ No newline at end of file From 3147a7121ae7645a1447f059ec615633755c34fa Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Tue, 7 Jan 2020 17:53:31 +0100 Subject: [PATCH 2/5] First throw, very very much inspired by https://hub.docker.com/r/continuumio/anaconda3 A git clone command has been added, to get a local copy of PyhDToolkit. The job of creating the appropriate conda environment with `make condaenv` is left to the user for now, as is `pip` installing `cpymad` afterwards. This will need testing, and later on to be integrated into the build. --- Dockerfile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4b192475 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM debian:latest + +ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 +ENV PATH /opt/conda/bin:$PATH + +# Updating system and getting some requirements +RUN apt-get update --fix-missing && apt-get install -y wget bzip2 ca-certificates \ + libglib2.0-0 libxext6 libsm6 libxrender1 \ + git mercurial subversion + +# Getting anaconda3 distribution +RUN wget --quiet https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh -O ~/anaconda.sh && \ + /bin/bash ~/anaconda.sh -b -p /opt/conda && \ + rm ~/anaconda.sh && \ + ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ + echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \ + echo "conda activate base" >> ~/.bashrc + +RUN apt-get install -y curl grep sed dpkg && \ + TINI_VERSION=`curl https://github.com/krallin/tini/releases/latest | grep -o "/v.*\"" | sed 's:^..\(.*\).$:\1:'` && \ + curl -L "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb" > tini.deb && \ + dpkg -i tini.deb && \ + rm tini.deb && \ + apt-get clean + +ENTRYPOINT [ "/usr/bin/tini", "--" ] + +CMD [ "git", "clone", "https://github.com/fsoubelet/PyhDToolkit.git" ] +CMD [ "pip", "install", "cpymad" ] +CMD [ "/bin/bash" ] \ No newline at end of file From c2988f339e8c4f1da38d88550f70a1e7ae790f75 Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Thu, 9 Jan 2020 18:31:47 +0100 Subject: [PATCH 3/5] Working container Dockerfile is working as wanted, and pushed to dockerhub Should be subject to minor changes Env file has been patched (this branch happened before the patch from develop) Another env file, specifically for the container build, has been added --- Dockerfile | 48 +++++++---- docker_conda_env.yml | 110 ++++++++++++++++++++++++ environment.yml | 200 +++++++++++++++++++++---------------------- 3 files changed, 238 insertions(+), 120 deletions(-) create mode 100644 docker_conda_env.yml diff --git a/Dockerfile b/Dockerfile index 4b192475..379f88d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,40 @@ -FROM debian:latest +# NOTA BENE +# YOU SHOULD RUN THIS CONTAINER WITH THE --init OPTION +# STEP 1 - Base image +FROM ubuntu:18.04 + +# STEP 2 & 3 - Environment variables needed by miniconda install ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 ENV PATH /opt/conda/bin:$PATH -# Updating system and getting some requirements -RUN apt-get update --fix-missing && apt-get install -y wget bzip2 ca-certificates \ - libglib2.0-0 libxext6 libsm6 libxrender1 \ - git mercurial subversion +# STEP 4 - Update Ubuntu and install necessary packages +RUN apt-get -qq update --fix-missing > /dev/null && \ + apt-get -qq install -y wget \ + bzip2 \ + ca-certificates \ + curl \ + git \ + build-essential > /dev/null && \ + apt-get clean > /dev/null && \ + rm -rf /var/lib/apt/lists/* -# Getting anaconda3 distribution -RUN wget --quiet https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh -O ~/anaconda.sh && \ - /bin/bash ~/anaconda.sh -b -p /opt/conda && \ - rm ~/anaconda.sh && \ +# STEP 5 - Install miniconda3 +RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh -O ~/miniconda.sh && \ + /bin/bash ~/miniconda.sh -b -p /opt/conda >/dev/null && \ + rm ~/miniconda.sh && \ + /opt/conda/bin/conda clean --all --quiet --yes && \ ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \ - echo "conda activate base" >> ~/.bashrc + echo "conda activate PHD" >> ~/.bashrc -RUN apt-get install -y curl grep sed dpkg && \ - TINI_VERSION=`curl https://github.com/krallin/tini/releases/latest | grep -o "/v.*\"" | sed 's:^..\(.*\).$:\1:'` && \ - curl -L "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb" > tini.deb && \ - dpkg -i tini.deb && \ - rm tini.deb && \ - apt-get clean +# STEP 6 - Get a copy of this package +# RUN git clone https://github.com/fsoubelet/PyhDToolkit /pyhdtoolkit +COPY . /pyhdtoolkit -ENTRYPOINT [ "/usr/bin/tini", "--" ] +# STEP 7 - Create the PHD conda environment +RUN conda env create --file /pyhdtoolkit/docker_conda_env.yml --force > /dev/null && \ + /opt/conda/bin/conda clean --all --quiet --yes > /dev/null -CMD [ "git", "clone", "https://github.com/fsoubelet/PyhDToolkit.git" ] -CMD [ "pip", "install", "cpymad" ] +# STEP 8 - Start a bash shell at runtime CMD [ "/bin/bash" ] \ No newline at end of file diff --git a/docker_conda_env.yml b/docker_conda_env.yml new file mode 100644 index 00000000..9d527c6e --- /dev/null +++ b/docker_conda_env.yml @@ -0,0 +1,110 @@ +name: PHD +channels: + - conda-forge + - defaults +dependencies: + - alabaster=0.7.12 + - attrs=19.3.0 + - babel=2.7.0 + - backcall=0.1.0 + - bleach=3.1.0 + - bzip2=1.0.8 + - ca-certificates=2019.11.28 + - certifi=2019.11.28 + - cffi=1.13.2 + - chardet=3.0.4 + - cmarkgfm=0.4.2 + - cryptography=2.8 + - cycler=0.10.0 + - decorator=4.4.1 + - docutils=0.15.2 + - freetype=2.10.0 + - future=0.18.2 + - h5py=2.10.0 + - hdf5=1.10.5 + - idna=2.8 + - imagesize=1.1.0 + - importlib_metadata=1.3.0 + - ipykernel=5.1.3 + - ipython=7.10.2 + - ipython_genutils=0.2.0 + - jedi=0.15.1 + - jinja2=2.10.3 + - joblib=0.14.1 + - jpype1=0.7 + - jupyter_client=5.3.3 + - jupyter_core=4.6.1 + - kiwisolver=1.1.0 + - libblas=3.8.0 + - libcblas=3.8.0 + - libcxx=9.0.0 + - libffi=3.2.1 + - liblapack=3.8.0 + - libopenblas=0.3.7 + - libpng=1.6.37 + - libsodium=1.0.17 + - llvm-openmp=9.0.0 + - markupsafe=1.1.1 + - matplotlib=3.1.2 + - matplotlib-base=3.1.2 + - more-itertools=8.0.2 + - ncurses=6.1 + - numpy=1.17.3 + - openssl=1.1.1d + - packaging=19.2 + - pandas=0.25.3 + - parso=0.5.2 + - pexpect=4.7.0 + - pickleshare=0.7.5 + - pip=19.3.1 + - pkginfo=1.5.0.1 + - pluggy=0.12.0 + - prompt_toolkit=3.0.2 + - ptyprocess=0.6.0 + - py=1.8.0 + - pycparser=2.19 + - pygments=2.5.2 + - pyopenssl=19.1.0 + - pyparsing=2.4.5 + - pysocks=1.7.1 + - pytest=5.3.2 + - python=3.7.3 + - python-dateutil=2.8.1 + - pytz=2019.3 + - pyzmq=18.1.1 + - readline=8.0 + - readme_renderer=24.0 + - requests=2.22.0 + - requests-toolbelt=0.9.1 + - scikit-learn=0.22 + - scipy=1.3.2 + - setuptools=42.0.2 + - six=1.13.0 + - snowballstemmer=2.0.0 + - sphinx=2.3.0 + - sphinxcontrib-applehelp=1.0.1 + - sphinxcontrib-devhelp=1.0.1 + - sphinxcontrib-htmlhelp=1.0.2 + - sphinxcontrib-jsmath=1.0.1 + - sphinxcontrib-qthelp=1.0.2 + - sphinxcontrib-serializinghtml=1.1.3 + - sqlite=3.30.1 + - tk=8.6.10 + - tornado=6.0.3 + - tqdm=4.40.2 + - traitlets=4.3.3 + - twine=2.0.0 + - urllib3=1.25.7 + - wcwidth=0.1.7 + - webencodings=0.5.1 + - wheel=0.33.6 + - xz=5.2.4 + - zeromq=4.3.2 + - zipp=0.6.0 + - zlib=1.2.11 + - pip: + - cmmnbuild-dep-manager==2.2.5 + - pytimber==2.7.0 + - sdds==0.1.3 + - tfs-pandas==1.0.3 + - cpymad==1.4.1 \ No newline at end of file diff --git a/environment.yml b/environment.yml index a9da4cc6..e11d386a 100644 --- a/environment.yml +++ b/environment.yml @@ -3,107 +3,105 @@ channels: - conda-forge - defaults dependencies: - - alabaster=0.7.12=py_0 - - appnope=0.1.0=py37_1000 - - attrs=19.3.0=py_0 - - babel=2.7.0=py_0 - - backcall=0.1.0=py_0 - - bleach=3.1.0=py_0 - - bzip2=1.0.8=h0b31af3_2 - - ca-certificates=2019.11.28=hecc5488_0 - - certifi=2019.11.28=py37_0 - - cffi=1.13.2=py37h33e799b_0 - - chardet=3.0.4=py37_1003 - - cmarkgfm=0.4.2=py37h0b31af3_2 - - cryptography=2.8=py37hafa8578_1 - - cycler=0.10.0=py_2 - - decorator=4.4.1=py_0 - - docutils=0.15.2=py37_0 - - freetype=2.10.0=h24853df_1 - - future=0.18.2=py37_0 - - h5py=2.10.0=nompi_py37h106b333_101 - - hdf5=1.10.5=nompi_h3e39495_1104 - - idna=2.8=py37_1000 - - imagesize=1.1.0=py_0 - - importlib_metadata=1.3.0=py37_0 - - ipykernel=5.1.3=py37h5ca1d4c_0 - - ipython=7.10.2=py37h5ca1d4c_0 - - ipython_genutils=0.2.0=py_1 - - jedi=0.15.1=py37_0 - - jinja2=2.10.3=py_0 - - joblib=0.14.1=py_0 - - jpype1=0.7=py37hbf1eeb5_0 - - jupyter_client=5.3.3=py37_1 - - jupyter_core=4.6.1=py37_0 - - kiwisolver=1.1.0=py37ha1b3eb9_0 - - libblas=3.8.0=14_openblas - - libcblas=3.8.0=14_openblas - - libcxx=9.0.0=h89e68fa_1 - - libffi=3.2.1=h6de7cb9_1006 - - libgfortran=4.0.0=2 - - liblapack=3.8.0=14_openblas - - libopenblas=0.3.7=h3d69b6c_5 - - libpng=1.6.37=h2573ce8_0 - - libsodium=1.0.17=h01d97ff_0 - - llvm-openmp=9.0.0=h40edb58_0 - - markupsafe=1.1.1=py37h0b31af3_0 - - matplotlib=3.1.2=py37_1 - - matplotlib-base=3.1.2=py37h11da6c2_1 - - more-itertools=8.0.2=py_0 - - ncurses=6.1=h0a44026_1002 - - numpy=1.17.3=py37hde6bac1_0 - - openssl=1.1.1d=h0b31af3_0 - - packaging=19.2=py_0 - - pandas=0.25.3=py37h4f17bb1_0 - - parso=0.5.2=py_0 - - pexpect=4.7.0=py37_0 - - pickleshare=0.7.5=py37_1000 - - pip=19.3.1=py37_0 - - pkginfo=1.5.0.1=py_0 - - pluggy=0.12.0=py_0 - - prompt_toolkit=3.0.2=py_0 - - ptyprocess=0.6.0=py_1001 - - py=1.8.0=py_0 - - pycparser=2.19=py37_1 - - pygments=2.5.2=py_0 - - pyopenssl=19.1.0=py37_0 - - pyparsing=2.4.5=py_0 - - pysocks=1.7.1=py37_0 - - pytest=5.3.2=py37_0 - - python=3.7.3=h5c2c468_2 - - python-dateutil=2.8.1=py_0 - - pytz=2019.3=py_0 - - pyzmq=18.1.1=py37h4bf09a9_0 - - readline=8.0=hcfe32e1_0 - - readme_renderer=24.0=py_0 - - requests=2.22.0=py37_1 - - requests-toolbelt=0.9.1=py_0 - - scikit-learn=0.22=py37h3dc85bc_1 - - scipy=1.3.2=py37h82752d6_0 - - setuptools=42.0.2=py37_0 - - six=1.13.0=py37_0 - - snowballstemmer=2.0.0=py_0 - - sphinx=2.3.0=py_0 - - sphinxcontrib-applehelp=1.0.1=py_0 - - sphinxcontrib-devhelp=1.0.1=py_0 - - sphinxcontrib-htmlhelp=1.0.2=py_0 - - sphinxcontrib-jsmath=1.0.1=py_0 - - sphinxcontrib-qthelp=1.0.2=py_0 - - sphinxcontrib-serializinghtml=1.1.3=py_0 - - sqlite=3.30.1=h93121df_0 - - tk=8.6.10=hbbe82c9_0 - - tornado=6.0.3=py37h0b31af3_0 - - tqdm=4.40.2=py_0 - - traitlets=4.3.3=py37_0 - - twine=2.0.0=py_0 - - urllib3=1.25.7=py37_0 - - wcwidth=0.1.7=py_1 - - webencodings=0.5.1=py_1 - - wheel=0.33.6=py37_0 - - xz=5.2.4=h1de35cc_1001 - - zeromq=4.3.2=h6de7cb9_2 - - zipp=0.6.0=py_0 - - zlib=1.2.11=h0b31af3_1006 + - alabaster=0.7.12 + - attrs=19.3.0 + - babel=2.7.0 + - backcall=0.1.0 + - bleach=3.1.0 + - bzip2=1.0.8 + - ca-certificates=2019.11.28 + - certifi=2019.11.28 + - cffi=1.13.2 + - chardet=3.0.4 + - cmarkgfm=0.4.2 + - cryptography=2.8 + - cycler=0.10.0 + - decorator=4.4.1 + - docutils=0.15.2 + - freetype=2.10.0 + - future=0.18.2 + - h5py=2.10.0 + - hdf5=1.10.5 + - idna=2.8 + - imagesize=1.1.0 + - importlib_metadata=1.3.0 + - ipykernel=5.1.3 + - ipython=7.10.2 + - ipython_genutils=0.2.0 + - jedi=0.15.1 + - jinja2=2.10.3 + - joblib=0.14.1 + - jpype1=0.7 + - jupyter_client=5.3.3 + - jupyter_core=4.6.1 + - kiwisolver=1.1.0 + - libblas=3.8.0 + - libcblas=3.8.0 + - libcxx=9.0.0 + - libffi=3.2.1 + - liblapack=3.8.0 + - libopenblas=0.3.7 + - libpng=1.6.37 + - libsodium=1.0.17 + - llvm-openmp=9.0.0 + - markupsafe=1.1.1 + - matplotlib=3.1.2 + - matplotlib-base=3.1.2 + - more-itertools=8.0.2 + - ncurses=6.1 + - numpy=1.17.3 + - openssl=1.1.1d + - packaging=19.2 + - pandas=0.25.3 + - parso=0.5.2 + - pexpect=4.7.0 + - pickleshare=0.7.5 + - pip=19.3.1 + - pkginfo=1.5.0.1 + - pluggy=0.12.0 + - prompt_toolkit=3.0.2 + - ptyprocess=0.6.0 + - py=1.8.0 + - pycparser=2.19 + - pygments=2.5.2 + - pyopenssl=19.1.0 + - pyparsing=2.4.5 + - pysocks=1.7.1 + - pytest=5.3.2 + - python=3.7.3 + - python-dateutil=2.8.1 + - pytz=2019.3 + - pyzmq=18.1.1 + - readline=8.0 + - readme_renderer=24.0 + - requests=2.22.0 + - requests-toolbelt=0.9.1 + - scikit-learn=0.22 + - scipy=1.3.2 + - setuptools=42.0.2 + - six=1.13.0 + - snowballstemmer=2.0.0 + - sphinx=2.3.0 + - sphinxcontrib-applehelp=1.0.1 + - sphinxcontrib-devhelp=1.0.1 + - sphinxcontrib-htmlhelp=1.0.2 + - sphinxcontrib-jsmath=1.0.1 + - sphinxcontrib-qthelp=1.0.2 + - sphinxcontrib-serializinghtml=1.1.3 + - sqlite=3.30.1 + - tk=8.6.10 + - tornado=6.0.3 + - tqdm=4.40.2 + - traitlets=4.3.3 + - twine=2.0.0 + - urllib3=1.25.7 + - wcwidth=0.1.7 + - webencodings=0.5.1 + - wheel=0.33.6 + - xz=5.2.4 + - zeromq=4.3.2 + - zipp=0.6.0 + - zlib=1.2.11 - pip: - cmmnbuild-dep-manager==2.2.5 - pytimber==2.7.0 From 766df614ec2c94703ad6496db19885c997379334 Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Fri, 10 Jan 2020 14:45:19 +0100 Subject: [PATCH 4/5] Documented container image build Container is well and tested. Changes are as follows: * Dockerfile now includes updating base conda * Makefile is updated with docker-build and docker-pull commands * README is updated with info on container image build, pull, and run commands including in a jupyterlab environment --- Dockerfile | 1 + Makefile | 35 +++++++++++++++++++---------- README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 79 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 379f88d1..a323c8b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,7 @@ RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.7.12.1-Linux-x rm ~/miniconda.sh && \ /opt/conda/bin/conda clean --all --quiet --yes && \ ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ + /opt/conda/bin/conda update -n base -c defaults conda --yes --quiet > /dev/null && \ echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \ echo "conda activate PHD" >> ~/.bashrc diff --git a/Makefile b/Makefile index 2a29b040..80108d59 100644 --- a/Makefile +++ b/Makefile @@ -13,23 +13,25 @@ E = \033[0m P = \033[95m R = \033[31m -.PHONY : help archive black checklist clean condaenv install isort lines pipreq uninstall tests +.PHONY : help archive black checklist clean condaenv docker-build docker-pull install isort lines pipreq uninstall tests all: install help: @echo "Please use 'make $(R)$(E)' where $(R)$(E) is one of:" - @echo " $(R) archive $(E) to create a tarball of this specific release." - @echo " $(R) black $(E) to recursively apply PEP8 formatting through the 'Black' cli tool." - @echo " $(R) checklist $(E) to print a pre-release check-list." - @echo " $(R) clean $(E) to recursively remove build, run, and bitecode files/dirs." - @echo " $(R) condaenv $(E) to 'conda install' the specific 'PHD' environment I use. Personnal." - @echo " $(R) install $(E) to 'pip install' this package into your activated environment." - @echo " $(R) isort $(E) to recursively sort import statements. Called by 'make black'." - @echo " $(R) lines $(E) to count lines of code with the 'tokei' tool." - @echo " $(R) pipreq $(E) to 'pip install' packages listed in 'requirements.txt' into your activated environment." - @echo " $(R) uninstall $(E) to uninstall the 'pyhdtoolkit' package from your activated environment." - @echo " $(R) tests $(E) to run tests with the the pytest package." + @echo " $(R) archive $(E) to create a tarball of this specific release." + @echo " $(R) black $(E) to recursively apply PEP8 formatting through the 'Black' cli tool." + @echo " $(R) checklist $(E) to print a pre-release check-list." + @echo " $(R) clean $(E) to recursively remove build, run, and bitecode files/dirs." + @echo " $(R) condaenv $(E) to 'conda install' the specific 'PHD' environment I use. Personnal." + @echo " $(R) docker-build $(E) to build a container image replicating the 'PHD' environment." + @echo " $(R) docker-pull $(E) to pull a pre-built image from Dockerhub." + @echo " $(R) install $(E) to 'pip install' this package into your activated environment." + @echo " $(R) isort $(E) to recursively sort import statements. Called by 'make black'." + @echo " $(R) lines $(E) to count lines of code with the 'tokei' tool." + @echo " $(R) pipreq $(E) to 'pip install' packages listed in 'requirements.txt' into your activated environment." + @echo " $(R) uninstall $(E) to uninstall the 'pyhdtoolkit' package from your activated environment." + @echo " $(R) tests $(E) to run tests with the the pytest package." archive: @echo "$(B)Creating tarball archive of this release.$(E)" @@ -74,6 +76,15 @@ condaenv: @ipython kernel install --user --name=PHD @conda deactivate +docker-build: + @echo "Building docker image with $(D)PHD$(E) conda environment, with tag $(P)simenv$(E)." + @docker build -t simenv . + @echo "Done. You can run this with $(P)docker run -it --init simenv$(E)." + +docker-pull: + @echo "Pulling docker image $(P)fsoubelet/simenv$(E) from Dockerhub." + @docker pull fsoubelet/simenv + install: black clean @echo "Installing this package to your active environment." @pip install . diff --git a/README.md b/README.md index 3a87b05d..4a274c38 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,23 @@ # PyhDToolkit: An all-in-one toolkit package for Python work in my PhD. -This repository is a package gathering a number of Python utilities for my PhD. +This repository is a package gathering a number of Python utilities for my work. ## Installation This code is compatible with `Python 3.6+`. -If for some reason you have a need for this package, first install the prerequisites with: +If for some reason you have a need for it, you should first install the prerequisites with: ```bash make pipreq ``` Then, you can simply install it with: ```bash -pip install -e git+https://github.com/fsoubelet/PyhDToolkit.git@master#egg=pyhdtoolkit +pip install --editable git+https://github.com/fsoubelet/PyhDToolkit.git@master#egg=pyhdtoolkit ``` -The `-e` flag should only be included if you intend to make some hotfix changes to the site-package. -If you intend on making actual changes, then you should clone this repository through VCS, and install it into your virtual environment with: +The `--editable` flag should only be included if you intend to make some hotfix changes to the site-package. +If you intend on making actual changes, then you should clone this repository through VCS, and install it into a virtual environment. +With `git`, this would be: ```bash git clone https://github.com/fsoubelet/PyhDToolkit.git cd PyhDToolkit @@ -35,8 +36,7 @@ make tests ## Standards, Tools and VCS -This repository respects the PyCharm docstring format (because it's the tool I use), and uses [Black][black_formatter] as a code formatter. -The default enforced line length is 120 characters. +This repository respects the PyCharm docstring format, and uses [Black][black_formatter] as a code formatter with a default enforced line length of 120 characters. You can lint the code with: ```bash make black @@ -45,11 +45,57 @@ make black VCS is done through [git][git_ref] and follows the [Gitflow][gitflow_ref] workflow. As a consequence, make sure to always install from `master`. +## Miscellaneous + +Feel free to explore the `Makefile` and make use of the functions it offers. +You will get an idea of what functionality is available to you by running: +```bash +make help +``` + +### Environment + +This repository currently comes with an `environment.yml` file to reproduce a fully compatible conda environment. +You can install this environment and add it to your ipython kernel by running: +```bash +make condaenv +``` + +### Container + +A Dockerfile is included if you want to build a container image from source. +You can do so, building with the tag `simenv`, with the command: +```bash +make docker-build +``` + +Alternatively, you can directly pull a pre-built image from Dockerhub with: +```bash +make docker-pull +``` + +You can then run your container in interactive mode, and use the already activated conda environment for your work. +It is highly advised to run with `--init` for zombie processes protection, see [Tini][tini_ref] for details. +Assuming you pulled the provided image from Dockerhub, the command is then: +```bash +docker run -it --init fsoubelet/simenv +``` + +If you want to do some exploration through a `jupyter` interface then you need to tell your container to install it first, as it is not bundled in miniconda, then add the custom environment kernelspec. +The following command will take care of all this: +```bash +docker run -it --init -p 8888:8888 fsoubelet/simenv /bin/bash -c "/opt/conda/bin/conda install -c conda-forge jupyterlab -y --quiet > /dev/null && mkdir /opt/notebooks && /opt/conda/envs/PHD/bin/ipython kernel install --user --name=PHD && /opt/conda/bin/jupyter lab --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser --allow-root" +``` + +You can then copy the provided token and head to `localhost:8888` on your local machine. + ## License -Copyright © 2019 Felix Soubelet. [MIT License][license] +Copyright © 2019-2020 Felix Soubelet. [MIT License][license] [black_formatter]: https://github.com/psf/black [gitflow_ref]: https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow [git_ref]: https://git-scm.com/ -[license]: https://github.com/fsoubelet/PyhDToolkit/blob/master/LICENSE \ No newline at end of file +[license]: https://github.com/fsoubelet/PyhDToolkit/blob/master/LICENSE +[oci_ref]: https://www.opencontainers.org/ +[tini_ref]: https://github.com/krallin/tini \ No newline at end of file From 0c4613d28371ca690d165e9ec6ed5355cb8f6c83 Mon Sep 17 00:00:00 2001 From: Felix Soubelet Date: Fri, 10 Jan 2020 14:54:33 +0100 Subject: [PATCH 5/5] Updated version for release --- pyhdtoolkit/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyhdtoolkit/__version__.py b/pyhdtoolkit/__version__.py index 2cb312fc..8ca4aa89 100644 --- a/pyhdtoolkit/__version__.py +++ b/pyhdtoolkit/__version__.py @@ -1,7 +1,7 @@ __title__ = "pyhdtoolkit" __description__ = "An all-in-one toolkit package to easy my Python work in my PhD." __url__ = "https://github.com/fsoubelet/PyhDToolkit" -__version__ = "0.1.0" +__version__ = "0.1.1" __author__ = "Felix Soubelet" __author_email__ = "felix.soubelet@cern.ch" __license__ = "MIT"