Skip to content

Commit 085b81b

Browse files
committed
updating Dockerfile for test, and github actions
1 parent cfb4787 commit 085b81b

File tree

4 files changed

+215
-34
lines changed

4 files changed

+215
-34
lines changed

.github/workflows/python-package.yml

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: Python package
52

63
on:
@@ -10,43 +7,47 @@ on:
107
branches: [ master ]
118

129
jobs:
13-
build-edm:
14-
strategy:
15-
matrix:
16-
os: [ubuntu-latest]
17-
runs-on: ${{ matrix.os }}
10+
build:
11+
runs-on: ubuntu-latest
1812
steps:
19-
- name: Checkout
13+
- name: Checkout repository
2014
uses: actions/checkout@v4
21-
- name: Cache EDM packages
22-
uses: actions/cache@v4
23-
with:
24-
path: ~/.cache
25-
key: ${{ runner.os }}--${{ hashFiles('requirements.txt') }}
26-
- name: Setup EDM
27-
uses: enthought/setup-edm-action@v3
15+
16+
- name: Set up Miniconda
17+
uses: conda-incubator/setup-miniconda@v3
2818
with:
29-
edm-version: 3.7.0
30-
- name: Install Python packages
19+
python-version: "3.11"
20+
auto-activate-base: false
21+
activate-environment: pyptv
22+
23+
- name: Install dependencies
24+
shell: bash -l {0}
3125
run: |
32-
edm install -y enable
33-
edm install -y numpy"==1.26.4"
34-
edm install -y matplotlib
35-
edm shell
36-
edm run -- python -m pip install optv==0.3.0 tqdm flake8 pytest pyptv \
37-
--index-url https://pypi.fury.io/pyptv \
38-
--extra-index-url https://pypi.org/simple
26+
conda install -y numpy==1.26.4 matplotlib pytest flake8 tqdm
27+
pip install optv==0.3.0 pyptv \
28+
--index-url https://pypi.fury.io/pyptv \
29+
--extra-index-url https://pypi.org/simple
30+
31+
- name: Setup test data
32+
shell: bash -l {0}
33+
run: |
34+
git clone https://github.com/openptv/test_cavity
35+
mkdir -p tests/test_cavity/parameters
36+
cp -r test_cavity/parameters/* tests/test_cavity/parameters/
37+
38+
- name: Verify environment
39+
shell: bash -l {0}
40+
run: python scripts/verify_environment.py
41+
42+
# Uncomment if you want to run linting
3943
# - name: Lint with flake8
44+
# shell: bash -l {0}
4045
# run: |
4146
# # stop the build if there are Python syntax errors or undefined names
4247
# flake8 . --count --select=E9,F63,F7,F82 --ignore=F821 --show-source --statistics
43-
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
48+
# # exit-zero treats all errors as warnings
4449
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
45-
- name: Test with pytest
46-
run: |
47-
# First clone test data to a specific location
48-
git clone https://github.com/openptv/test_cavity
49-
# Copy necessary parameter files
50-
cp -r test_cavity/parameters/* tests/test_cavity/parameters/
51-
# Run tests with more verbose output and fail on first error
52-
edm run -- pytest -v -x --tb=short
50+
51+
- name: Run tests
52+
shell: bash -l {0}
53+
run: pytest -v -x --tb=short

DEVELOP.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# PyPTV Development Guide
2+
3+
## Testing with Docker
4+
5+
The easiest way to test PyPTV without affecting your local environment is using Docker:
6+
7+
```bash
8+
# Run all tests in Docker
9+
./run_docker_tests.sh
10+
```
11+
12+
### Docker Test Environment Details
13+
14+
The test environment is defined in `Dockerfile.test` and uses:
15+
- Ubuntu latest
16+
- Python 3.11
17+
- Miniconda
18+
- NumPy 1.26.4
19+
- OpenPTV (optv) 0.3.0
20+
21+
### Debugging in Docker
22+
23+
To debug issues interactively:
24+
25+
```bash
26+
# Build the test image
27+
docker build -t pyptv-test -f Dockerfile.test .
28+
29+
# Run container interactively
30+
docker run -it --rm pyptv-test bash
31+
32+
# Inside container, run tests:
33+
./run_tests.sh
34+
35+
# Or run specific components:
36+
python scripts/verify_environment.py
37+
pytest -v -x tests/test_environment.py
38+
```
39+
40+
## Local Development Setup
41+
42+
If you prefer local development:
43+
44+
1. Install EDM (Enthought Deployment Manager)
45+
2. Create and activate environment:
46+
```bash
47+
edm install -y enable
48+
edm install -y numpy==1.26.4
49+
edm install -y matplotlib
50+
edm shell
51+
```
52+
53+
3. Install dependencies:
54+
```bash
55+
python -m pip install optv==0.3.0 tqdm flake8 pytest pyptv \
56+
--index-url https://pypi.fury.io/pyptv \
57+
--extra-index-url https://pypi.org/simple
58+
```
59+
60+
## Development Workflow
61+
62+
1. Create feature branch:
63+
```bash
64+
git checkout -b feature/your-feature-name
65+
```
66+
67+
2. Make changes and test:
68+
```bash
69+
# Run tests in Docker (recommended)
70+
./run_docker_tests.sh
71+
72+
# Or run tests locally
73+
pytest -v -x --tb=short
74+
```
75+
76+
3. Lint code:
77+
```bash
78+
flake8 . --count --select=E9,F63,F7,F82 --ignore=F821 --show-source --statistics
79+
```
80+
81+
4. Submit PR:
82+
- Ensure all tests pass
83+
- Update documentation if needed
84+
- Follow code style guidelines
85+
86+
## Version Management
87+
88+
- Bump version: `python bump_version.py --patch`
89+
- Build package: `python -m build`
90+
- Install locally: `pip install dist/pyptv-{version}-py3-none-any.whl`
91+
92+
## Code Style Guidelines
93+
94+
- Use Black formatter (line length 88)
95+
- Follow PEP 8 naming conventions
96+
- Add docstrings for public functions
97+
- Keep functions focused and small
98+
- Write tests for new features
99+
100+
## Dependencies
101+
102+
Critical version requirements:
103+
- Python >= 3.10
104+
- NumPy == 1.26.4
105+
- OpenPTV (optv) == 0.3.0
106+
- See `pyproject.toml` for complete list
107+
108+
## Common Issues
109+
110+
1. EDM Installation Problems:
111+
- Verify EDM version (3.7.0 required)
112+
- Check system dependencies
113+
114+
2. Test Data Issues:
115+
- Ensure test_cavity repository is cloned
116+
- Verify parameter files are copied correctly
117+
118+
3. Version Conflicts:
119+
- Use `scripts/verify_environment.py` to check versions
120+
- Follow exact versions in `pyproject.toml`
121+
122+
## Getting Help
123+
124+
- Open an issue on GitHub
125+
- Contact the mailing list: openptv@googlegroups.com
126+
- Check existing documentation: http://openptv-python.readthedocs.io

Dockerfile.test

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Use Ubuntu as base image to match GitHub Actions
2+
FROM ubuntu:latest
3+
4+
# Set environment variables
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
ENV PATH="/root/miniconda3/bin:${PATH}"
7+
8+
# Install system dependencies
9+
RUN apt-get update && apt-get install -y \
10+
wget \
11+
git \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
# Install Miniconda
15+
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh \
16+
&& bash miniconda.sh -b -p /root/miniconda3 \
17+
&& rm miniconda.sh
18+
19+
# Initialize conda for bash
20+
RUN conda init bash
21+
22+
# Create and activate conda environment
23+
RUN conda create -y -n pyptv python=3.11 \
24+
&& echo "conda activate pyptv" >> ~/.bashrc
25+
26+
# Set working directory
27+
WORKDIR /app
28+
29+
# Copy project files
30+
COPY . .
31+
32+
# Setup test environment script
33+
RUN echo '#!/bin/bash \n\
34+
source ~/.bashrc && \
35+
conda install -y numpy==1.26.4 matplotlib pytest flake8 tqdm && \
36+
pip install optv==0.3.0 pyptv \
37+
--index-url https://pypi.fury.io/pyptv \
38+
--extra-index-url https://pypi.org/simple && \
39+
git clone https://github.com/openptv/test_cavity && \
40+
mkdir -p tests/test_cavity/parameters && \
41+
cp -r test_cavity/parameters/* tests/test_cavity/parameters/ && \
42+
python scripts/verify_environment.py && \
43+
pytest -v -x --tb=short \
44+
' > run_tests.sh && chmod +x run_tests.sh
45+
46+
# Default command
47+
CMD ["./run_tests.sh"]

run_docker_tests.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# Build the test container
4+
docker build -t pyptv-test -f Dockerfile.test .
5+
6+
# Run tests
7+
docker run --rm pyptv-test

0 commit comments

Comments
 (0)