Skip to content

recursive obj subsetting#97

Merged
2 commits merged intodevelopfrom
DATAUP-692-ensure-specs
Feb 8, 2022
Merged

recursive obj subsetting#97
2 commits merged intodevelopfrom
DATAUP-692-ensure-specs

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Feb 8, 2022

  • I updated the README.md docs to reflect this change.

For changes to the codebase:

  • I have written tests to cover this change.
  • This is not a breaking API change OR
  • This is a breaking API change and I have incremented the API version and added a summary to CHANGELOG.md.

@ghost ghost requested review from ialarmedalien, slebras and zhlu9890 as code owners February 8, 2022 04:51
Comment thread relation_engine_server/main.py
Comment thread relation_engine_server/utils/config.py
try:
conf = service_conf[name]
auth = (_CONF["db_user"], _CONF["db_pass"])
print("auth is", auth)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was showing up in logs

Comment on lines +231 to +249
def is_obj_subset_rec(
l: Union[dict, list, float, str, int],
r: Union[dict, list, float, str, int],
):
"""
Compare two JSON objects, to see if, essentially, l <= r
If comparing dicts, recursively compare
If comparing lists, shallowly compare. For now, YAGN more
"""
if isinstance(l, dict) and isinstance(r, dict):
return all(
[k in r.keys() and is_obj_subset_rec(l[k], r[k]) for k in l.keys()]
) # ignore: typing
elif isinstance(l, list) and isinstance(r, list):
return all([le in r for le in l])
else:
return l == r # noqa: E741


Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first guess on how to compare the local/server specs was just local.items() <= server.items() with the assumption that ArangoDB would only add default parameters. Kind of worked, but ended up working better with recursive subset checks ..

Copy link
Copy Markdown
Collaborator

@ialarmedalien ialarmedalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add a comment about checking the develop branch rather than master

@ghost ghost merged commit 02abc7f into develop Feb 8, 2022
@ghost ghost deleted the DATAUP-692-ensure-specs branch February 8, 2022 18:04
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant