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

v0.1.2 #95

Merged
merged 54 commits into from
Feb 28, 2024
Merged
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b747f7e
Add support for UUIDs in request payloads
samamorgan Sep 19, 2023
8e399d9
Refactor util tests
samamorgan Sep 19, 2023
ab9bfe2
Merge pull request #86 from Lightmatter/feature/uuid-parsing
samamorgan Sep 19, 2023
5caec44
Unify parent accessor methods
samamorgan Oct 27, 2023
3e36785
Implement `delattr`
samamorgan Oct 27, 2023
8b50af1
temp commit
jdiaz5513 Oct 3, 2023
5b3275f
Add Program formations
samamorgan Oct 5, 2023
96dab5e
WIP
samamorgan Oct 27, 2023
690031d
Remove decorators
samamorgan Oct 27, 2023
c30f217
Fix bug in `find_model_id` and improve docs
samamorgan Oct 27, 2023
0cee096
Fix type hint for backwards-compatibility
samamorgan Oct 27, 2023
d6a7a66
Fix cache for older versions of Python
samamorgan Oct 27, 2023
e1f854a
Fix type annotation for function
samamorgan Oct 27, 2023
e4eefb3
Fix another type annotation
samamorgan Oct 27, 2023
b451953
Chain all `AttributeErrors` for better traceback
samamorgan Oct 27, 2023
4a00a23
Fix parent recursion
samamorgan Oct 27, 2023
3a32fd4
Clean up paths
samamorgan Oct 27, 2023
54417f8
Add dynamic patient fixture
samamorgan Oct 27, 2023
eaf20c9
WIP - `Program` read tested
samamorgan Oct 28, 2023
f870433
Remove tests from coverage check
samamorgan Oct 31, 2023
730e1d6
Fix patient fixture cassette dir
samamorgan Oct 31, 2023
2daf528
Finish program tests
samamorgan Oct 31, 2023
fb49196
Finish tests
samamorgan Oct 31, 2023
e56ec4a
Remove .envrc
samamorgan Oct 31, 2023
bc41a26
Revert import change
samamorgan Oct 31, 2023
dd8b754
Remove old shelve dbm on error
samamorgan Nov 3, 2023
e658124
Add `pre-commit`
samamorgan Nov 3, 2023
e08a09d
Bump test matrix version
samamorgan Nov 3, 2023
c37ab88
Fix coverage comment
samamorgan Nov 3, 2023
41ed3d7
Fix permissions
samamorgan Nov 3, 2023
b0ac959
Use lesser permissions
samamorgan Nov 3, 2023
f19c70c
Fix coverage report txt
samamorgan Nov 3, 2023
985bc41
Remove doc8 from precommit
samamorgan Nov 3, 2023
d8ef8b6
Rename models to avoid naming conflict
samamorgan Nov 3, 2023
f15eef7
Revert "Use lesser permissions"
samamorgan Nov 3, 2023
80f1c99
Merge pull request #90 from zest-derm/samm/parent-accessors
samamorgan Feb 28, 2024
1ae997c
Merge remote-tracking branch 'Lightmatter/develop' into juliand/zst-1157
samamorgan Feb 28, 2024
d764dd0
Fix `PatientProgram` parent accessors
samamorgan Feb 28, 2024
ebfee7b
Run all matrix jobs even if one fails
samamorgan Feb 28, 2024
8d2eb93
Add concurrency limiter
samamorgan Feb 28, 2024
69d0296
Merge pull request #92 from zest-derm/juliand/zst-1157
samamorgan Feb 28, 2024
c062822
Revamp test/publish actions
samamorgan Feb 28, 2024
ff714c9
Bump semver
samamorgan Feb 28, 2024
ce802ec
Fix package groups
samamorgan Feb 28, 2024
65c25b5
Update RTD command
samamorgan Feb 28, 2024
f7315db
Add Python version to coverage comment
samamorgan Feb 28, 2024
368671e
Add dynamic package metadata
samamorgan Feb 28, 2024
06ec959
Get rid of Tomli
samamorgan Feb 28, 2024
6686882
Move welkin import
samamorgan Feb 28, 2024
916aa9c
Update sphinx deps
samamorgan Feb 28, 2024
0e249ea
Update RTD config
samamorgan Feb 28, 2024
3557658
Merge pull request #94 from Lightmatter/feature/actions-revamp
samamorgan Feb 28, 2024
d14f6ad
Merge branch 'main' into develop
samamorgan Feb 28, 2024
0c0eb5b
Suggested fixes
samamorgan Feb 28, 2024
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
Next Next commit
Add support for UUIDs in request payloads
Resolves #77
samamorgan committed Sep 19, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b747f7e3b502acdff511b070c30c423549c11266
3 changes: 3 additions & 0 deletions test/test_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import uuid
from datetime import date, datetime, timedelta, timezone

from welkin.util import (
@@ -24,6 +25,7 @@ def test_clean_request_payload():
"int": [-sys.maxsize, 0, sys.maxsize],
"float": [sys.float_info.min, 1, sys.float_info.max],
"bool": [True, False],
"uuid4": uuid.uuid4(),
"none": None,
}
payload_copy = dict(payload)
@@ -35,6 +37,7 @@ def test_clean_request_payload():
assert cleaned["date"] == "2022-09-15T00:00:00.000Z"
assert cleaned["dict"]["nested"]["date"] == "2022-09-15T00:00:00.000Z"
assert cleaned["list"][0] == "2022-09-15T23:00:00.000Z"
assert isinstance(cleaned["uuid4"], str)


def test_clean_json_list():
48 changes: 28 additions & 20 deletions welkin/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from datetime import date, datetime, timezone
from typing import Any
from uuid import UUID

from welkin.models.base import SchemaBase

@@ -38,36 +40,42 @@ def _build_resources(instance: type, attribute_name: str, value: type = None) ->
setattr(val, attribute_name, value)


def clean_data(value: Any) -> Any:
"""Clean data for JSON serialization.
Args:
value (Any): The value to clean.
Returns:
Any: The cleaned value.
"""
if isinstance(value, datetime):
return clean_datetime(value)
elif isinstance(value, date):
return clean_date(value)
elif isinstance(value, dict):
return clean_request_payload(value)
elif isinstance(value, list):
return clean_json_list(value)
elif isinstance(value, UUID):
return str(value)

# No cleaning needed
return value


def clean_request_payload(payload: dict) -> dict:
result = {}
for k, v in payload.items():
if isinstance(v, datetime):
result[k] = clean_datetime(v)
elif isinstance(v, date):
result[k] = clean_date(v)
elif isinstance(v, dict):
result[k] = clean_request_payload(v)
elif isinstance(v, list):
result[k] = clean_json_list(v)
else:
result[k] = v
result[k] = clean_data(v)

return result


def clean_json_list(data: list) -> list:
result = []
for item in data:
if isinstance(item, datetime):
result.append(clean_datetime(item))
elif isinstance(item, date):
result.append(clean_date(item))
elif isinstance(item, dict):
result.append(clean_request_payload(item))
elif isinstance(item, list):
result.append(clean_json_list(item))
else:
result.append(item)
result.append(clean_data(item))

return result