Skip to content

Commit

Permalink
👔 Use regex to not override existing YAML type declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
shnizzedy committed Sep 5, 2024
1 parent 9c34a1e commit de18553
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CPAC/utils/bids_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,8 +1165,8 @@ def _check_value_type(
def coerce_data_config_strings(contents: str) -> str:
"""Coerge `subject_id` and `unique_id` to be strings."""
for key in ["subject_id: ", "unique_id: "]:
contents = contents.replace(key, f"{key}!!str ")
return contents
contents = re.sub(f"{key}(?!!!)", f"{key}!!str ", contents)
return contents.replace(": !!str !!", ": !!")


def load_cpac_data_config(data_config_file, participant_labels, aws_input_creds):
Expand Down
4 changes: 4 additions & 0 deletions CPAC/utils/tests/configs/github_2144.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
subject_id: 01
unique_id: 02
derivatives_dir: /fprep/sub-0151
- site: site-1
subject_id: !!str 02
unique_id: 02
derivatives_dir: /fprep/sub-0151

0 comments on commit de18553

Please sign in to comment.