Skip to content

Commit

Permalink
Merge pull request #107 from MilagrosMarin/main
Browse files Browse the repository at this point in the history
Add last PR changes to CHANGELOG, bump version, blackformatting `tests`
  • Loading branch information
Thinh Nguyen authored Mar 22, 2024
2 parents 16c845e + 9f8b212 commit 190150d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 46 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ on:
jobs:
make_github_release:
uses: datajoint/.github/.github/workflows/make_github_release.yaml@main
pypi_release:
needs: make_github_release
uses: datajoint/.github/.github/workflows/pypi_release.yaml@main
secrets:
TWINE_USERNAME: ${{secrets.TWINE_USERNAME}}
TWINE_PASSWORD: ${{secrets.TWINE_PASSWORD}}
with:
UPLOAD_URL: ${{needs.make_github_release.outputs.release_upload_url}}
mkdocs_release:
uses: datajoint/.github/.github/workflows/mkdocs_release.yaml@main
permissions:
Expand Down
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.

## [0.2.11] - 2023-01-04
## [0.2.12] - 2024-03-22

+ Add - pytest
+ Fix - minor bugfix in tests
+ Update - clean up notebook
+ Update - Elements installed directly from GitHub instead of PyPI
+ Update - Black formatting `tests`

## [0.2.11] - 2024-01-04

+ Fix - docstring typo
+ Fix - `dj.config()` setup moved to `tutorial_pipeline.py` instead of `__init__.py`
+ Bugfix - Resolved AttributeError from the latest update of the YAML dependency
+ Update - Flowchart images to increase consistency with other DataJoint Elements
+ Update - Elements installed directly from GitHub instead of PyPI

## [0.2.10] - 2023-11-20

Expand Down
2 changes: 1 addition & 1 deletion element_deeplabcut/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
Package metadata
"""
__version__ = "0.2.11"
__version__ = "0.2.12"
31 changes: 17 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def pipeline():
"session": pipeline.session,
"model": pipeline.model,
"train": pipeline.train,
"Device": pipeline.Device
"Device": pipeline.Device,
}

if _tear_down:
Expand Down Expand Up @@ -80,14 +80,17 @@ def insert_upstreams(pipeline):
model.VideoRecording.insert1(
{**recording_key, "device": "Camera1"}, skip_duplicates=True
)

video_files = [
"./example_data/inbox/from_top_tracking-DataJoint-2023-10-11/videos/train1.mp4"
"./example_data/inbox/from_top_tracking-DataJoint-2023-10-11/videos/train1.mp4"
]

model.VideoRecording.File.insert(
[{**recording_key, "file_id": v_idx, "file_path": Path(f)}
for v_idx, f in enumerate(video_files)], skip_duplicates=True
[
{**recording_key, "file_id": v_idx, "file_path": Path(f)}
for v_idx, f in enumerate(video_files)
],
skip_duplicates=True,
)

yield
Expand Down Expand Up @@ -115,19 +118,19 @@ def insert_dlc_model(pipeline):
config_file_rel = "from_top_tracking-DataJoint-2023-10-11/config.yaml"

model.Model.insert_new_model(
model_name="from_top_tracking_model_test",
dlc_config=config_file_rel,
shuffle=1,
trainingsetindex=0,
model_description="Model in example data: from_top_tracking model",
prompt=False
)
model_name="from_top_tracking_model_test",
dlc_config=config_file_rel,
shuffle=1,
trainingsetindex=0,
model_description="Model in example data: from_top_tracking model",
prompt=False,
)

yield

if _tear_down:
model.Model.delete()


@pytest.fixture(scope="session")
def insert_pose_estimation_task(pipeline, recording_info, insert_dlc_model):
Expand All @@ -139,7 +142,7 @@ def insert_pose_estimation_task(pipeline, recording_info, insert_dlc_model):
"recording_id": "1",
}
task_key = {**recording_key, "model_name": "from_top_tracking_model_test"}

model.PoseEstimationTask.insert1(
{
**task_key,
Expand Down
35 changes: 22 additions & 13 deletions tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,30 @@ def test_generate_pipeline(pipeline):
assert "trainingsetindex" in model.Model.heading.secondary_attributes
assert "x_pos" in model.PoseEstimation.BodyPartPosition.heading.secondary_attributes
assert "y_pos" in model.PoseEstimation.BodyPartPosition.heading.secondary_attributes
assert "likelihood" in model.PoseEstimation.BodyPartPosition.heading.secondary_attributes
assert (
"likelihood"
in model.PoseEstimation.BodyPartPosition.heading.secondary_attributes
)

assert len(train.schema.list_tables()) == 5


def test_recording_info(pipeline, recording_info):
model = pipeline["model"]
expected_rec_info = {'subject': 'subject6',
'session_datetime': datetime.datetime(2021, 6, 2, 14, 4, 22),
'recording_id': 1,
'px_height': 500,
'px_width': 500,
'nframes': 60000,
'fps': 60,
'recording_datetime': None,
'recording_duration': 1000.0}
expected_rec_info = {
"subject": "subject6",
"session_datetime": datetime.datetime(2021, 6, 2, 14, 4, 22),
"recording_id": 1,
"px_height": 500,
"px_width": 500,
"nframes": 60000,
"fps": 60,
"recording_datetime": None,
"recording_duration": 1000.0,
}

rec_info = model.RecordingInfo.fetch1()

assert rec_info == expected_rec_info


Expand All @@ -48,8 +53,12 @@ def test_pose_estimation(pipeline, pose_estimation):

assert set(body_parts) == {"head", "tailbase"}

head_x = (model.PoseEstimation.BodyPartPosition & {"body_part": "head"}).fetch1("x_pos")
tail_y = (model.PoseEstimation.BodyPartPosition & {"body_part": "tailbase"}).fetch1("y_pos")
head_x = (model.PoseEstimation.BodyPartPosition & {"body_part": "head"}).fetch1(
"x_pos"
)
tail_y = (model.PoseEstimation.BodyPartPosition & {"body_part": "tailbase"}).fetch1(
"y_pos"
)

assert len(head_x) == len(tail_y)
assert (round(head_x.std())) == 129
Expand Down
9 changes: 1 addition & 8 deletions tests/tutorial_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,7 @@ def get_dlc_processed_data_dir() -> str:
return None


__all__ = [
"lab",
"subject",
"session",
"train",
"model",
"Device"
]
__all__ = ["lab", "subject", "session", "train", "model", "Device"]

# Activate schemas -------------

Expand Down

0 comments on commit 190150d

Please sign in to comment.