Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 10 additions & 6 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
branches: [ "master", "vibe/streamlit-app-90c846" ]

jobs:
test:
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ uv.lock

# Mistral memory file
#MistralMemory.md
# Trigger CI
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions src/otGpxTrack/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/otGpxTrack/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
20 changes: 12 additions & 8 deletions streamlitApp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,32 @@ 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
try:
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)
Expand Down
Loading