-
Notifications
You must be signed in to change notification settings - Fork 61
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
[Core] Port 12078 reduce port system load #1318
base: main
Are you sure you want to change the base?
Conversation
entities_at_port_with_properties = await ocean.port_client.search_entities( | ||
user_agent_type, | ||
include_params=["blueprint", "identifier"] + [ | ||
f"properties.{prop}" for prop in resource.port.entity.mappings.properties | ||
], | ||
query=query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing relations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move it to a separate function for constructing query?
unique_entities = get_unique_entities(objects_diff[0].entity_selector_diff.passed, entities_at_port_with_properties) | ||
modified_objects = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unique_entities = get_unique_entities(objects_diff[0].entity_selector_diff.passed, entities_at_port_with_properties) | |
modified_objects = [] | |
changed_entities = get_unique_entities(objects_diff[0].entity_selector_diff.passed, entities_at_port_with_properties) | |
modified_objects = [] |
query = { | ||
"combinator": "and", | ||
"rules": [ | ||
{ | ||
"combinator": "or", | ||
"rules": [ | ||
{ | ||
"property": "$identifier", | ||
"operator": "=", | ||
"value": entity.identifier, | ||
} | ||
for entity in objects_diff[0].entity_selector_diff.passed | ||
] | ||
} | ||
] | ||
} | ||
entities_at_port_with_properties = await ocean.port_client.search_entities( | ||
user_agent_type, | ||
include_params=["blueprint", "identifier"] + [ | ||
f"properties.{prop}" for prop in resource.port.entity.mappings.properties | ||
], | ||
query=query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a need to search for every batch size? I think the minimum should be 20
port_ocean/core/utils/utils.py
Outdated
return [ | ||
third_party_entity | ||
for third_party_entity in third_party_entities | ||
if not any( | ||
are_entities_equal(third_party_entity, port_entity) | ||
for port_entity in port_entities | ||
) | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return [ | |
third_party_entity | |
for third_party_entity in third_party_entities | |
if not any( | |
are_entities_equal(third_party_entity, port_entity) | |
for port_entity in port_entities | |
) | |
] | |
port_entity_ids = {port_entity.identifier for port_entity in port_entities} | |
return [ | |
third_party_entity | |
for third_party_entity in third_party_entities | |
if third_party_entity.identifier not in port_entity_ids | |
or not any( | |
are_entities_equal(third_party_entity, port_entity) | |
for port_entity in port_entities | |
if port_entity.identifier == third_party_entity.identifier | |
) | |
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be more efficient
diff = DeepDiff( | ||
first_entity.properties, second_entity.properties, ignore_order=True | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about relations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about dates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how are you handling decimal numbers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to decide on some size / limit of when we are stopping the compare and decide to sync it to port? as it can be quite cpu intensive for big objects
logger.bind( | ||
changed_entities=len(unique_entities), | ||
total_entities=len(objects_diff[0].entity_selector_diff.passed), | ||
).info("Upserting changed entities") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.bind( | |
changed_entities=len(unique_entities), | |
total_entities=len(objects_diff[0].entity_selector_diff.passed), | |
).info("Upserting changed entities") | |
logger.info("Upserting changed entities", changed_entities=len(unique_entities), | |
total_entities=len(objects_diff[0].entity_selector_diff.passed)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for below
Description
What - reduce the amount of upserts we send to port api
Why - many of the upserts does not contain an actual change, reduce load from port api
How - check if the entity from the third party has a change from the entity in port, and only if there is an actual change, upsert the entity
Type of change
Please leave one option from the following and delete the rest:
All tests should be run against the port production environment(using a testing org).
Core testing checklist
Integration testing checklist
examples
folder in the integration directory.Preflight checklist