Skip to content

Commit

Permalink
chore: add more logging, bump dependencies (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum authored Jul 18, 2024
1 parent db8cb53 commit 6cb4bd6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
rev: v0.5.2
hooks:
- id: ruff
# args: [
Expand Down
8 changes: 5 additions & 3 deletions dsp_permissions_scripts/oap/oap_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ def _read_all_oaps_from_files(
folder = _get_project_data_path(shortcode, mode)
res_oaps: list[ResourceOap] = []
val_oaps: list[ValueOap] = []
for file in folder.glob("**/*.json"):
all_files = list(folder.glob("**/*.json"))
for file in all_files:
content = file.read_text(encoding="utf-8")
if "_values_" in file.name:
val_oaps.append(ValueOap.model_validate_json(content))
else:
res_oaps.append(ResourceOap.model_validate_json(content))
logger.info(f"Read {len(res_oaps)} resource OAPs and {len(val_oaps)} value OAPs from {len(all_files)} files")
return res_oaps, val_oaps


Expand All @@ -91,8 +93,8 @@ def sort_algo(x: ValueOap) -> str:
deserialized_resource_iris.append(res_iri)

remaining_res_oaps = [oap for oap in res_oaps if oap.resource_iri not in deserialized_resource_iris]
for res_oap in remaining_res_oaps:
oaps.append(Oap(resource_oap=res_oap, value_oaps=[]))
oaps.extend(Oap(resource_oap=res_oap, value_oaps=[]) for res_oap in remaining_res_oaps)

oaps.sort(key=lambda oap: oap.resource_oap.resource_iri if oap.resource_oap else "")
logger.debug(f"Grouped {len(res_oaps)} resource OAPs and {len(val_oaps)} value OAPs into {len(oaps)} OAPs")
return oaps
52 changes: 26 additions & 26 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ pydantic = "^2.8.2"

[tool.poetry.group.dev.dependencies]
mypy = "^1.10.1"
types-requests = "^2.32.0.20240622"
types-requests = "^2.32.0.20240712"
python-dotenv = "^1.0.1"
ruff = "^0.5.1"
ruff = "^0.5.2"
pre-commit = "^3.7.1"
pytest = "^8.2.2"
pytest-unordered = "^0.6.1"
Expand Down

0 comments on commit 6cb4bd6

Please sign in to comment.