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

Path sanitization hotfix #107

Merged
merged 3 commits into from
Aug 2, 2024
Merged
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
10 changes: 5 additions & 5 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ channels:

dependencies:
- python
- ffmpeg<6.1.0
- ffmpeg
- imageio
- imageio-ffmpeg
- imageio-ffmpeg >=0.5.0
- av
- attrs
- pandas
- simplejson
- h5py>=3.8.0
- h5py >=3.8.0
- hdmf
- numpy
- opencv<4.9.0
- numpy <2.0.0
- opencv
- pynwb
- ndx-pose
- pytest
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies = [
"pandas",
"simplejson",
"imageio",
"imageio-ffmpeg",
"imageio-ffmpeg>=0.5.0",
"av"]
dynamic = ["version", "readme"]

Expand Down
24 changes: 14 additions & 10 deletions sleap_io/io/slp.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,20 @@
is_embedded = True

# Basic path resolution.
video_path = Path(video_path)
if not video_path.exists():
# Check for the same filename in the same directory as the labels file.
video_path_ = Path(labels_path).parent / video_path.name
if video_path_.exists():
video_path = video_path_
else:
# TODO (TP): Expand capabilities of path resolution to support more
# complex path finding strategies.
pass
video_path = Path(Path(video_path).as_posix().replace("\\", "/"))

try:
if not video_path.exists():
# Check for the same filename in the same directory as the labels file.
video_path_ = Path(labels_path).parent / video_path.name
if video_path_.exists():
video_path = video_path_

Check warning on line 75 in sleap_io/io/slp.py

View check run for this annotation

Codecov / codecov/patch

sleap_io/io/slp.py#L75

Added line #L75 was not covered by tests
else:
# TODO (TP): Expand capabilities of path resolution to support more
# complex path finding strategies.
pass
except OSError:
pass

Check warning on line 81 in sleap_io/io/slp.py

View check run for this annotation

Codecov / codecov/patch

sleap_io/io/slp.py#L80-L81

Added lines #L80 - L81 were not covered by tests
talmo marked this conversation as resolved.
Show resolved Hide resolved

# Convert video path to string.
video_path = video_path.as_posix()
Expand Down
2 changes: 1 addition & 1 deletion sleap_io/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# Define package version.
# This is read dynamically by setuptools in pyproject.toml to determine the release version.
__version__ = "0.1.6"
__version__ = "0.1.7"
3 changes: 3 additions & 0 deletions tests/io/test_nwb.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def test_default_metadata_overwriting(nwbfile, slp_predictions_with_provenance):

def test_complex_case_append(nwbfile, centered_pair):
labels = load_slp(centered_pair)
labels.clean(tracks=True)
nwbfile = append_nwb_data(labels, nwbfile)

# Test matching number of processing modules
Expand Down Expand Up @@ -169,6 +170,7 @@ def test_complex_case_append(nwbfile, centered_pair):

def test_complex_case_append_with_timestamps_metadata(nwbfile, centered_pair):
labels = load_slp(centered_pair)
labels.clean(tracks=True)

number_of_frames = 1100 # extracted using ffmpeg probe
video_sample_rate = 15.0 # 15 Hz extracted using ffmpeg probe for the video stream
Expand Down Expand Up @@ -238,6 +240,7 @@ def test_typical_case_write(slp_typical, tmp_path):

def test_get_timestamps(nwbfile, centered_pair):
labels = load_slp(centered_pair)
labels.clean(tracks=True)
nwbfile = append_nwb_data(labels, nwbfile)
processing = nwbfile.processing["SLEAP_VIDEO_000_centered_pair_low_quality"]
assert True
Expand Down
Loading