-
Notifications
You must be signed in to change notification settings - Fork 7
Add allow_upsert option to LineDelimitedJSONImporter #765
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
base: stable
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -49,6 +49,10 @@ def __init__(self, branch: str, schema: RelationshipSchemaAPI, data: Any | dict, | |||||||||||||
| setattr(self, prop, None) | ||||||||||||||
| self._relationship_metadata = None | ||||||||||||||
|
|
||||||||||||||
| elif isinstance(data, RelatedNodeBase): | ||||||||||||||
| # Handle when value is already a RelatedNode - extract its identifying data | ||||||||||||||
| data = {"id": data.id, "hfid": data.hfid, "__typename": data.typename} | ||||||||||||||
|
Comment on lines
+52
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Preserve Prompt for AI agents
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| elif isinstance(data, list): | ||||||||||||||
| data = {"hfid": data} | ||||||||||||||
| elif not isinstance(data, dict): | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,31 +34,26 @@ def wrapped_task_output(self, start: str, end: str = "[green]done") -> Generator | |||||||||||||||
| if self.console: | ||||||||||||||||
| self.console.print(f"{end}") | ||||||||||||||||
|
|
||||||||||||||||
| def identify_many_to_many_relationships( | ||||||||||||||||
| self, node_schema_map: dict[str, MainSchemaTypesAPI] | ||||||||||||||||
| ) -> dict[tuple[str, str], str]: | ||||||||||||||||
| # Identify many to many relationships by src/dst couples | ||||||||||||||||
| def identify_many_relationships(self, node_schema_map: dict[str, MainSchemaTypesAPI]) -> dict[tuple[str, str], str]: | ||||||||||||||||
| # Identify many relationships (both one-way and bidirectional many-to-many) | ||||||||||||||||
| many_relationship_identifiers: dict[tuple[str, str], str] = {} | ||||||||||||||||
|
|
||||||||||||||||
| for node_schema in node_schema_map.values(): | ||||||||||||||||
| for relationship in node_schema.relationships: | ||||||||||||||||
| if ( | ||||||||||||||||
| relationship.cardinality != "many" | ||||||||||||||||
| or not relationship.optional | ||||||||||||||||
| or not relationship.identifier | ||||||||||||||||
| or relationship.peer not in node_schema_map | ||||||||||||||||
| ): | ||||||||||||||||
| continue | ||||||||||||||||
| for peer_relationship in node_schema_map[relationship.peer].relationships: | ||||||||||||||||
| if peer_relationship.cardinality != "many" or peer_relationship.peer != node_schema.kind: | ||||||||||||||||
| continue | ||||||||||||||||
|
|
||||||||||||||||
| forward = many_relationship_identifiers.get((node_schema.kind, relationship.peer)) | ||||||||||||||||
| backward = many_relationship_identifiers.get((relationship.peer, node_schema.kind)) | ||||||||||||||||
| forward = many_relationship_identifiers.get((node_schema.kind, relationship.peer)) | ||||||||||||||||
| backward = many_relationship_identifiers.get((relationship.peer, node_schema.kind)) | ||||||||||||||||
|
|
||||||||||||||||
| # Record the relationship only if it's not known in one way or another | ||||||||||||||||
| if not forward and not backward: | ||||||||||||||||
| many_relationship_identifiers[node_schema.kind, relationship.peer] = relationship.identifier | ||||||||||||||||
| # Record the relationship only if it's not known in one way or another | ||||||||||||||||
| # This avoids duplicating bidirectional many-to-many relationships | ||||||||||||||||
| if not forward and not backward: | ||||||||||||||||
| many_relationship_identifiers[node_schema.kind, relationship.peer] = relationship.identifier | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: This now exports one-way Prompt for AI agents
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| return many_relationship_identifiers | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -69,7 +64,7 @@ async def retrieve_many_to_many_relationships( | |||||||||||||||
| page_number = 1 | ||||||||||||||||
| page_size = 50 | ||||||||||||||||
|
|
||||||||||||||||
| many_relationship_identifiers = list(self.identify_many_to_many_relationships(node_schema_map).values()) | ||||||||||||||||
| many_relationship_identifiers = list(self.identify_many_relationships(node_schema_map).values()) | ||||||||||||||||
| many_relationships: list[dict[str, Any]] = [] | ||||||||||||||||
|
|
||||||||||||||||
| if not many_relationship_identifiers: | ||||||||||||||||
|
|
||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
P3: Don't hand-edit this generated CLI doc; update the source definition and regenerate the MDX instead.
Prompt for AI agents