diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b9bbbf2..fcdc39a 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -4,7 +4,7 @@ on: push: branches: [ "master" ] pull_request: - branches: [ "master" ] + branches: [ "master", "vibe/streamlit-app-90c846" ] jobs: test: @@ -19,14 +19,18 @@ jobs: with: python-version: "3.10" - - name: Install uv - run: pip install uv + - name: Install dependencies with conda + uses: conda-incubator/setup-miniconda@v3 + with: + python-version: "3.10" + channels: conda-forge + channel-priority: strict - - name: Install dependencies - run: uv sync + - name: Install openturns + run: conda install -y openturns gpxpy matplotlib numpy pandas pytest - name: Run tests - run: uv run pytest test/ -v + run: python -m pytest test/ -v build-docs: name: Build Documentation diff --git a/.gitignore b/.gitignore index 3d439fd..3126860 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ uv.lock # Mistral memory file #MistralMemory.md +# Trigger CI diff --git a/README.md b/README.md index 551a0fe..d9edc54 100644 --- a/README.md +++ b/README.md @@ -140,3 +140,4 @@ Contributions are welcome! Please open an issue or submit a pull request. - Inspired by the firstexample/gpxAnalyse.py script - Uses OpenTURNS for statistical analysis - Built with modern Python tooling (uv, pytest) +# Test CI diff --git a/src/otGpxTrack/Base.py b/src/otGpxTrack/Base.py index 722fdff..45170d7 100644 --- a/src/otGpxTrack/Base.py +++ b/src/otGpxTrack/Base.py @@ -60,7 +60,7 @@ def __init__(self, gpx_file_path): def _load_gpx(self): """Load and parse the GPX file.""" - with open(self.gpx_file_path, "r") as f: + with open(self.gpx_file_path, "rb") as f: self.gpx = gpxpy.parse(f) def _extract_points(self): @@ -378,8 +378,8 @@ def simulate_ar1_speeds(self, segment_indices, sigma_tot=2.5, phi=0.9, n_sims=10 # Calculate statistics using OpenTURNS mean_speed = v_simulees.computeMean()[0] - lower = ot.Sample.computeQuantilePerComponent(v_simulees, 0.025)[0] - upper = ot.Sample.computeQuantilePerComponent(v_simulees, 0.975)[0] + lower = ot.Sample.computeQuantilePerComponent(v_simulees, 0.025)[0][0] + upper = ot.Sample.computeQuantilePerComponent(v_simulees, 0.975)[0][0] return mean_speed, lower, upper, v_simulees diff --git a/src/otGpxTrack/main.py b/src/otGpxTrack/main.py index 89e7eff..53d6488 100644 --- a/src/otGpxTrack/main.py +++ b/src/otGpxTrack/main.py @@ -25,7 +25,7 @@ def __init__(self, gpx_file_path): def _load_gpx(self): """Load and parse the GPX file.""" - with open(self.gpx_file_path, "r") as f: + with open(self.gpx_file_path, "rb") as f: self.gpx = gpxpy.parse(f) def _extract_points(self): diff --git a/streamlitApp/app.py b/streamlitApp/app.py index fb1c353..15f0f03 100644 --- a/streamlitApp/app.py +++ b/streamlitApp/app.py @@ -89,13 +89,15 @@ def main(): with cols[i]: if (example_dir / example_file).exists(): if st.button(f"Load {example_file}", use_container_width=True): + # Create a temporary file with the example content with open(example_dir / example_file, "rb") as f: - uploaded_file = f.read() - uploaded_file = tempfile.NamedTemporaryFile( - delete=False, suffix=".gpx" - ) - uploaded_file.write(uploaded_file) - uploaded_file.seek(0) + file_content = f.read() + temp_file = tempfile.NamedTemporaryFile( + delete=False, suffix=".gpx", mode='wb' + ) + temp_file.write(file_content) + temp_file.close() + uploaded_file = temp_file if uploaded_file is not None: # Process the uploaded file @@ -103,14 +105,16 @@ def main(): with st.spinner("Processing GPX file..."): # Save to temp file if hasattr(uploaded_file, "name"): + # This is a temp file from example loading temp_file_path = uploaded_file.name else: + # This is a Streamlit UploadedFile temp_file = tempfile.NamedTemporaryFile( - delete=False, suffix=".gpx" + delete=False, suffix=".gpx", mode='wb' ) temp_file.write(uploaded_file.getvalue()) - temp_file_path = temp_file.name temp_file.close() + temp_file_path = temp_file.name # Load the track track = GpxTrack(temp_file_path)