Skip to content

Commit

Permalink
Merge branch 'release/0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoubelet committed Jan 10, 2020
2 parents fbd44bc + 0c4613d commit 6b3c1df
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 24 deletions.
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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

# 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/*

# 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 && \
/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

# STEP 6 - Get a copy of this package
# RUN git clone https://github.com/fsoubelet/PyhDToolkit /pyhdtoolkit
COPY . /pyhdtoolkit

# 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

# STEP 8 - Start a bash shell at runtime
CMD [ "/bin/bash" ]
35 changes: 23 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)<target>$(E)' where $(R)<target>$(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)"
Expand Down Expand Up @@ -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 .
Expand Down
49 changes: 39 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ 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
Expand All @@ -35,8 +36,7 @@ make tests

## Standards, Tools and VCS

This repository respects the PyCharm docstring format, 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
Expand All @@ -45,21 +45,49 @@ 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 Goodies
## Miscellaneous

Feel free to explore the `Makefile` and make use of the functions it offers.
You can get an idea of what is available to you by running:
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
```

A Dockerfile and later on an [OCI][oci_ref]-compliant file are to come.
### 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

Expand All @@ -69,4 +97,5 @@ Copyright &copy; 2019-2020 Felix Soubelet. [MIT License][license]
[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
[oci_ref]: https://www.opencontainers.org/
[oci_ref]: https://www.opencontainers.org/
[tini_ref]: https://github.com/krallin/tini
110 changes: 110 additions & 0 deletions docker_conda_env.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pyhdtoolkit/__version__.py
Original file line number Diff line number Diff line change
@@ -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"
Empty file.
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ tqdm
pandas
pytest
matplotlib
numpy
numpy
pandas
scipy

0 comments on commit 6b3c1df

Please sign in to comment.