Skip to content

Commit

Permalink
chore: Automatically populating Schema.property_ordering in function …
Browse files Browse the repository at this point in the history
…declaration schemas.

PiperOrigin-RevId: 683296356
vertex-sdk-bot authored and copybara-github committed Oct 7, 2024
1 parent 66572e0 commit 09ea389
Showing 3 changed files with 0 additions and 42 deletions.
35 changes: 0 additions & 35 deletions tests/unit/vertexai/test_generative_models.py
Original file line number Diff line number Diff line change
@@ -158,23 +158,6 @@
},
],
},
"ordered": {
"type": "OBJECT",
"properties": {
"a": {"type": "stRIng"},
"b": {"type": "Integer"},
"c": {
"type": "objeCT",
"properties": {
"x": {"type": "string"},
"y": {"type": "number"},
"z": {"type": "integer"},
},
"property_ordering": ["z", "y", "x"],
},
},
"propertyOrdering": ["b", "a", "c"],
},
},
}
_RENAMING_EXPECTED_SCHEMA = {
@@ -208,25 +191,7 @@
},
],
},
"ordered": {
"type_": "OBJECT",
"properties": {
"a": {"type_": "STRING"},
"b": {"type_": "INTEGER"},
"c": {
"type_": "OBJECT",
"properties": {
"x": {"type_": "STRING"},
"y": {"type_": "NUMBER"},
"z": {"type_": "INTEGER"},
},
"property_ordering": ["z", "y", "x"], # explicit order kept
},
},
"property_ordering": ["b", "a", "c"], # explicit order kept
},
},
"property_ordering": ["names", "date", "ordered"], # implicit order added
}


5 changes: 0 additions & 5 deletions vertexai/generative_models/_generative_models.py
Original file line number Diff line number Diff line change
@@ -2094,11 +2094,6 @@ def _fix_schema_dict_for_gapic_in_place(schema_dict: Dict[str, Any]) -> None:
if properties := schema_dict.get("properties"):
for property_schema in properties.values():
_fix_schema_dict_for_gapic_in_place(property_schema)
if (
"property_ordering" not in schema_dict
and "propertyOrdering" not in schema_dict
):
schema_dict["property_ordering"] = list(properties.keys())

if any_of := (schema_dict.get("any_of") or schema_dict.get("anyOf")):
for any_of_schema in any_of:
2 changes: 0 additions & 2 deletions vertexai/tokenization/_tokenizers.py
Original file line number Diff line number Diff line change
@@ -370,8 +370,6 @@ def _schema_traverse(self, schema: openapi.Schema) -> openapi.Schema:
if "required" in schema:
self._texts.extend(schema.required)
counted_schema.required = schema.required
if "property_ordering" in schema:
counted_schema.property_ordering = schema.property_ordering
if "items" in schema:
counted_schema_items = self._schema_traverse(schema.items)
counted_schema.items = counted_schema_items

0 comments on commit 09ea389

Please sign in to comment.