Skip to content

Commit

Permalink
Add dockerfile for running PTM in a container (#38)
Browse files Browse the repository at this point in the history
* Add if-main clause to cli

* Move top-level confest.py to project root

* Add dockerfile

* Remove extra whitespace

* Upgrade micromamba base image

* Undo style change

* Add __init__ file to tests root directory

* updates to get tests working locally

One still does not work but it will with a change in my next PR

* Fix precommit error

---------

Co-authored-by: Kristen Thyng <kthyng@gmail.com>
  • Loading branch information
ahmad-axds and kthyng authored Feb 5, 2025
1 parent afc38d0 commit c8dcd9d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: 1.6.0
hooks:
- id: interrogate
exclude: ^(docs|setup.py|tests)
exclude: ^(docs|setup.py|tests|conftest.py)
args: [--config=pyproject.toml]

- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM mambaorg/micromamba:2.0.5-debian12

ENV PROJECT_NAME=particle-tracking-manager
ENV PROJECT_ROOT=/opt/particle-tracking-manager

COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml /tmp/environment.yml
RUN micromamba install -y -n base -f /tmp/environment.yml && \
micromamba clean --all --yes && \
rm /tmp/environment.yml

COPY --chown=$MAMBA_USER:$MAMBA_USER particle_tracking_manager $PROJECT_ROOT/particle_tracking_manager
COPY --chown=$MAMBA_USER:$MAMBA_USER tests $PROJECT_ROOT/tests
COPY --chown=$MAMBA_USER:$MAMBA_USER pyproject.toml setup.cfg conftest.py README.md $PROJECT_ROOT/

WORKDIR $PROJECT_ROOT/

ENTRYPOINT ["micromamba", "run", "python", "-m", "particle_tracking_manager.cli"]
File renamed without changes.
4 changes: 4 additions & 0 deletions particle_tracking_manager/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,7 @@ def main():
# # Remove the handler at the end of the loop
# m.logger.removeHandler(file_handler)
# file_handler.close()


if __name__ == "__main__":
main()
Empty file added tests/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_setup():
No drifters are run due to oceanmodel=None
"""
ret_value = os.system(
f"python {ptm.__path__[0]}/cli.py ocean_model=test lon=-151 lat=59 use_auto_landmask=True start_time='2000-1-1'"
f"ptm ocean_model=test lon=-151 lat=59 use_auto_landmask=True start_time='2000-1-1' --dry-run"
)
assert ret_value == 0

Expand Down

0 comments on commit c8dcd9d

Please sign in to comment.