Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a dev container to facilitate easy development environment #277

Merged
merged 29 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4ddc2a6
WIP: Add dev container, but permission issue remain when running as u…
markspec Sep 6, 2023
743cbda
Updates
markspec Sep 8, 2023
a2f2187
Update docs for dev environment.
markspec Sep 8, 2023
d4ecebc
Fix linting.
markspec Sep 8, 2023
264351d
More linting.
markspec Sep 8, 2023
19c180c
Fix ssh issue with pushing from container.
markspec Sep 8, 2023
8979414
WIP: Add dev container, but permission issue remain when running as u…
markspec Sep 6, 2023
47267c0
Updates
markspec Sep 8, 2023
13b77e4
Update docs for dev environment.
markspec Sep 8, 2023
5211c51
Fix linting.
markspec Sep 8, 2023
a510871
More linting.
markspec Sep 8, 2023
eca9b68
Fix ssh issue with pushing from container.
markspec Sep 8, 2023
f79028e
Updates to the devenvonment for jupyter integration.
markspec Sep 21, 2023
d028ee5
Add notebook with segy ingestion and export.
markspec Sep 25, 2023
302913a
Merge branch '276-dev-container' of github.com:markspec/mdio-python i…
markspec Sep 25, 2023
c82edf7
Prettier updates.
markspec Sep 25, 2023
a94eb72
Merge branch 'main' into 276-dev-container
markspec Sep 25, 2023
c1074d3
Merge branch 'main' into 276-dev-container
markspec Oct 2, 2023
f90f59d
Merge branch 'main' into 276-dev-container
markspec Oct 16, 2023
40b9f4b
Tidy up files based on PR feedback.
markspec Nov 2, 2023
bd4d749
Update docs/development_env.md
tasansal Nov 3, 2023
5198678
Update CONTRIBUTING.md
tasansal Nov 3, 2023
eb7cada
Update docs/development_env.md
tasansal Nov 3, 2023
ba51a12
Removed example notebook for segy ingestion and export.
markspec Nov 3, 2023
e22665b
Merge branch '276-dev-container' of github.com:markspec/mdio-python i…
markspec Nov 3, 2023
f33b124
consolidate dev container to contributing.md
tasansal Nov 3, 2023
4f467ce
remove redundant link
tasansal Nov 3, 2023
f0198dd
lint
tasansal Nov 3, 2023
eaa0a4d
Merge branch 'main' into 276-dev-container
tasansal Nov 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .devcontainer/Dockerfile
markspec marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ARG PYTHON_VERSION=3.11
ARG LINUX_DISTRO=bookworm

# FROM python:${PYTHON_VERSION}-${LINUX_DISTRO}
FROM mcr.microsoft.com/devcontainers/python:1-${PYTHON_VERSION}-${LINUX_DISTRO}

# Install git for nox pre-commit
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
&& rm -rf /var/lib/apt/lists/*

# Poetry
ARG POETRY_VERSION="1.6.1"
# RUN if [ "${POETRY_VERSION}" != "none" ]; then su vscode -c "umask 0002 && pip3 install poetry==${POETRY_VERSION}"; fi
RUN if [ "${POETRY_VERSION}" != "none" ]; then bash -c "umask 0002 && pip3 install poetry==${POETRY_VERSION}"; fi

# Nox
ARG NOX_VERSION="2023.4.22"
# RUN if [ "${NOX_VERSION}" != "none" ]; then su vscode -c "umask 0002 && pip3 install nox-poetry nox==${NOX_VERSION}"; fi
RUN if [ "${NOX_VERSION}" != "none" ]; then bash -c "umask 0002 && pip3 install nox-poetry nox==${NOX_VERSION}"; fi

# Nox poetry
ARG NOX_POETRY_VERSION="1.0.3"
# RUN if [ "${NOX_POETRY_VERSION}" != "none" ]; then su vscode -c "umask 0002 && pip3 install nox-poetry nox-poetry==${NOX_POETRY_VERSION}"; fi
RUN if [ "${NOX_POETRY_VERSION}" != "none" ]; then bash -c "umask 0002 && pip3 install nox-poetry nox-poetry==${NOX_POETRY_VERSION}"; fi

# Extra python packages for dev
RUN bash -c "umask 0002 && pip3 install msgpack ipykernel"

# Create venv
RUN python -m venv /opt/venv
RUN poetry config virtualenvs.create false
ENV PATH="/opt/venv/bin:$PATH"

# Extra python packages for dev
RUN bash -c "umask 0002 && pip3 install msgpack ipykernel"

# Allow users to update venv
RUN chmod -R 777 /opt/venv
43 changes: 43 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": {
"post_create_script": "bash ./.devcontainer/post-install.sh"
},
// Forward 8787 to enable us to view dask dashboard
"forwardPorts": [8787],
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"settings": {
"python.terminal.activateEnvInCurrentTerminal": true,
"python.defaultInterpreterPath": "/opt/venv/bin/python"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"vscode-icons-team.vscode-icons",
"wayou.vscode-todo-highlight",
"streetsidesoftware.code-spell-checker"
]
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root",
"updateRemoteUserUID": true,
"mounts": [
// Re-use local Git configuration
"source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig_tmp,type=bind,consistency=cached",
"source=${localEnv:HOME}/.gitconfig,target=/root/.gitconfig_tmp,type=bind,consistency=cached",
"source=${localEnv:SCRATCH_DIR}/${localEnv:USER},target=/scratch/,type=bind,consistency=cached"
]
}
12 changes: 12 additions & 0 deletions .devcontainer/post-install.sh
markspec marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cp -f /root/.gitconfig_tmp /root/.gitconfig
cp -f /home/vscode/.gitconfig_tmp /home/vscode/.gitconfig
chmod 777 /home/vscode/.gitconfig
git config --global --add safe.directory `pwd`
# Enable ssh with github for git push
ssh-keygen -f "/root/.ssh/known_hosts" -R "github.com"
# Setup venv
source /opt/venv/bin/activate
# Poetry cmds
poetry config virtualenvs.create false
# poetry install --with dev --no-ansi --all-extras
# poetry shell
151 changes: 151 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
debugging/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# ruff
.ruff_cache/

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# IDE settings
.vscode/
.idea/

# tests
mdio1/*
*/mdio1/*
pytest-of-*
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/jupyter_execute/

# PyBuilder
.pybuilder/
Expand Down Expand Up @@ -112,6 +113,7 @@ venv/
ENV/
env.bak/
venv.bak/
venv*/

# Spyder project settings
.spyderproject
Expand Down Expand Up @@ -143,3 +145,9 @@ cython_debug/
# IDE settings
.vscode/
.idea/

# tests
mdio1/*
*/mdio1/*
pytest-of-*
tmp/
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ Request features on the [Issue Tracker].

## How to set up your development environment

You need Python 3.7+ and the following tools:
You need Python 3.9+ and the following tools:

- [Poetry]
- [Nox]
- [nox-poetry]

A [dev container](./docs/development_env.md) has been setup to provide a clean environment with the required dependencies.

## How to install and run MDIO
tasansal marked this conversation as resolved.
Show resolved Hide resolved

Install the package with development requirements:

```console
Expand Down
10 changes: 10 additions & 0 deletions docs/development_env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Development Environment

To facilitate development on different systems a [dev container](https://containers.dev/) has been added. This should seamlessly enable development for users of [VSCode](https://code.visualstudio.com/docs/devcontainers/containers) on systems with docker installed.

For contributing guidelines please look here [link](../CONTRIBUTING.md)

### known issues:
markspec marked this conversation as resolved.
Show resolved Hide resolved

- Some effort was take to run without using root inside the container. However nox always seemed to have permissions issues which I've been unable to fix.
- `git config --global --add safe.directory \`pwd\` ` Might be needed inside the container.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ notebooks/compression
usage
reference
contributing
Development Environment <development_env>
Code of Conduct <codeofconduct>
License <license>
Changelog <https://github.com/TGSAI/mdio-python/releases>
Expand Down
Loading
Loading