-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abc79bf
commit ff4151a
Showing
3 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Project Name | ||
|
||
## Running `run_pipeline.py` | ||
|
||
To run the `run_pipeline.py` script directly, use the following command: | ||
|
||
```bash | ||
python code/src/run_pipeline.py | ||
``` | ||
|
||
Make sure you have all the necessary dependencies installed. You can install them using: | ||
|
||
```pip install -r requirements.txt``` | ||
|
||
Running Tests | ||
To run the tests, you can use pytest. Run the following command: | ||
|
||
To run the tests with coverage, use: | ||
|
||
```pytest code/tests``` | ||
|
||
This will execute all the tests and provide a coverage report. | ||
|
||
```pytest code/tests --cov=code/src``` | ||
|
||
## Example: Using pipeline.py in a new script | ||
|
||
To use the `pipeline.py` in another script, follow these steps: | ||
|
||
1. Create a new Python file (e.g., `new_script.py`) in your project directory. | ||
|
||
2. Add the following code to `new_script.py`: | ||
|
||
```python | ||
from src.pipeline import main as pipeline_main | ||
|
||
# Define your parameters | ||
params = { | ||
"video_path": "/path/to/your/video.mp4", | ||
"OUTPUT_DIR": "/path/to/output/directory", | ||
"tracker": "/path/to/tracker/config.yaml", | ||
"model_path": "/path/to/model/weights.pt", | ||
"write_to_local": True | ||
} | ||
|
||
# Run the pipeline and get the processed data | ||
processed_data = pipeline_main(params) | ||
|
||
# Now you can use processed_data as needed | ||
print(processed_data) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pytest | ||
from src.utils import video_utils | ||
|
||
|
||
def test_extract_datetime_from_filename(): | ||
filename = "2_2018-04-14_10-06-19.mp4" | ||
datetime = video_utils.extract_datetime_from_filename(filename) | ||
assert str(datetime) == "2018-04-14 10:06:19" | ||
|
||
|
||
def test_write_counts_to_json(): | ||
"""Expected behavior for output inference""" | ||
data = { | ||
"out_count": 10, | ||
"in_count": 5, | ||
"net_count": 5, | ||
"frame_rate": 30, | ||
"duration_seconds": 30, | ||
"relative_frame_times": [0, 1, 2, 3, 4], | ||
"frame_detections": [0, 1, 2, 3, 4], | ||
} | ||
video_utils.write_counts_to_json(data, "/tmp") | ||
assert True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pytest | ||
from datetime import datetime | ||
from src.utils.video_utils import extract_datetime_from_filename | ||
|
||
def test_extract_datetime_from_filename_valid(): | ||
filename = "1234_2023-10-05_14-30-00.mp4" | ||
expected_datetime = datetime(2023, 10, 5, 14, 30, 0) | ||
result = extract_datetime_from_filename(filename) | ||
assert result == expected_datetime | ||
|
||
def test_extract_datetime_from_filename_invalid_format(): | ||
filename = "invalid_filename.mp4" | ||
with pytest.raises(ValueError, match="Filename format doesn't match expected pattern"): | ||
extract_datetime_from_filename(filename) | ||
|
||
def test_extract_datetime_from_filename_invalid_date(): | ||
filename = "1234_2023-13-05_14-30-00.mp4" # Invalid month | ||
with pytest.raises(ValueError, match="Invalid date or time format in filename"): | ||
extract_datetime_from_filename(filename) |