Skip to content

Commit

Permalink
Merge pull request #92 from MilagrosMarin/element-dlc-test
Browse files Browse the repository at this point in the history
update `model.py`,tutorial notebook,`changelog`, and `version`
  • Loading branch information
Thinh Nguyen authored Oct 26, 2023
2 parents be8256f + fba8810 commit c887ab8
Show file tree
Hide file tree
Showing 4 changed files with 877 additions and 823 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
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.9] - 2023-10-18

+ Update - DLC project directory (named v2) of example data
+ Update - The mounting strategy to update the environment variables
+ Update - Add a new tutorial notebook
+ Fix - Rename pipeline link in README

## [0.2.8] - 2023-08-07

+ Update - GitHub Actions with new reusable workflows
Expand Down
37 changes: 15 additions & 22 deletions element_deeplabcut/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def extract_new_body_parts(cls, dlc_config: dict, verbose: bool = True):
"""Returns list of body parts present in dlc config, but not BodyPart table.
Args:
dlc_config (str or dict): path to a config.y*ml, or dict of such contents.
dlc_config ( varchar(255) ): Path to a config.y*ml.
verbose (bool): Default True. Print both existing and new items to console.
"""
if not isinstance(dlc_config, dict):
Expand Down Expand Up @@ -257,7 +257,7 @@ def insert_from_config(
"""Insert all body parts from a config file.
Args:
dlc_config (str or dict): path to a config.y*ml, or dict of such contents.
dlc_config ( varchar(255) ): Path to a config.y*ml.
descriptions (list): Optional. List of strings describing new body parts.
prompt (bool): Optional, default True. Prompt for confirmation before insert.
"""
Expand Down Expand Up @@ -365,8 +365,8 @@ def insert_new_model(
Args:
model_name (str): User-friendly name for this model.
dlc_config (str or dict): path to a config.y*ml, or dict of such contents.
shuffle (int): Shuffled or not as 1 or 0.
dlc_config ( varchar(255) ): Path to a config.y*ml.
shuffle (int): Which shuffle of the training dataset.
trainingsetindex (int): Index of training fraction list in config.yaml.
model_description (str): Optional. Description of this model.
model_prefix (str): Optional. Filename prefix used across DLC project
Expand All @@ -377,21 +377,18 @@ def insert_new_model(
from deeplabcut.utils.auxiliaryfunctions import GetScorerName # isort:skip

# handle dlc_config being a yaml file
if not isinstance(dlc_config, dict):
dlc_config_fp = find_full_path(get_dlc_root_data_dir(), Path(dlc_config))
assert dlc_config_fp.exists(), (
"dlc_config is neither dict nor filepath" + f"\n Check: {dlc_config_fp}"
)
if dlc_config_fp.suffix in (".yml", ".yaml"):
with open(dlc_config_fp, "rb") as f:
dlc_config = yaml.safe_load(f)
if isinstance(params, dict):
dlc_config.update(params)
dlc_config_fp = find_full_path(get_dlc_root_data_dir(), Path(dlc_config))
assert dlc_config_fp.exists(), (
"dlc_config is not a filepath" + f"\n Check: {dlc_config_fp}"
)
if dlc_config_fp.suffix in (".yml", ".yaml"):
with open(dlc_config_fp, "rb") as f:
dlc_config = yaml.safe_load(f)
if isinstance(params, dict):
dlc_config.update(params)

# ---- Get and resolve project path ----
project_path = find_full_path(
get_dlc_root_data_dir(), dlc_config.get("project_path", project_path)
)
project_path = dlc_config_fp.parent
dlc_config["project_path"] = project_path.as_posix() # update if different
root_dir = find_root_directory(get_dlc_root_data_dir(), project_path)

Expand Down Expand Up @@ -452,11 +449,7 @@ def insert_new_model(
):
print("Canceled insert.")
return
# ---- Save DJ-managed config ----
try:
_ = dlc_reader.save_yaml(project_path, dlc_config)
except PermissionError:
pass

# ____ Insert into table ----
with cls.connection.transaction:
cls.insert1(model_dict)
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.8"
__version__ = "0.2.9"
Loading

0 comments on commit c887ab8

Please sign in to comment.