Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions acceptance/bin/print_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@
>>> # Test positive + negative filters (AND logic)
>>> test(test_requests, ["//api", "^/jobs"], False, False)
R4 POST

>>> # --unique collapses consecutive duplicate requests (like uniq), e.g. repeated GET polls
>>> dup_requests = [
... {"method": "POST", "path": "/api/2.0/idx", "body": {"n": 1}},
... {"method": "GET", "path": "/api/2.0/idx"},
... {"method": "GET", "path": "/api/2.0/idx"},
... ]
>>> [x["method"] for x in filter_requests(dup_requests, ["//idx"], True, False, unique=True)]
['POST', 'GET']

>>> # Only consecutive duplicates collapse; a repeat after another request is kept
>>> seq = [
... {"method": "GET", "path": "/api/2.0/idx"},
... {"method": "DELETE", "path": "/api/2.0/idx"},
... {"method": "GET", "path": "/api/2.0/idx"},
... {"method": "GET", "path": "/api/2.0/idx"},
... ]
>>> [x["method"] for x in filter_requests(seq, ["//idx"], True, False, unique=True)]
['GET', 'DELETE', 'GET']
"""

import os
Expand Down Expand Up @@ -104,7 +123,7 @@ def read_json_many(s):
assert result == [{"method": "GET"}, {"method": "POST"}], result


def filter_requests(requests, path_filters, include_get, should_sort):
def filter_requests(requests, path_filters, include_get, should_sort, unique=False):
"""Filter requests based on method and path filters."""
positive_filters = []
negative_filters = []
Expand Down Expand Up @@ -145,6 +164,13 @@ def filter_requests(requests, path_filters, include_get, should_sort):
if should_sort:
filtered_requests.sort(key=str)

if unique:
deduped = []
for req in filtered_requests:
if not deduped or deduped[-1] != req:
deduped.append(req)
filtered_requests = deduped

return filtered_requests


Expand All @@ -155,6 +181,11 @@ def main():
parser.add_argument("--get", action="store_true", help="Include GET requests (excluded by default)")
parser.add_argument("--keep", action="store_true", help="Keep out.requests.json file after processing")
parser.add_argument("--sort", action="store_true", help="Sort requests before output")
parser.add_argument(
"--unique",
action="store_true",
help="Collapse consecutive duplicate requests (like uniq), e.g. repeated GET polls",
)
parser.add_argument("--oneline", action="store_true", help="Print output with one request per line")
parser.add_argument("--fname", default="out.requests.txt")
args = parser.parse_args()
Expand All @@ -175,7 +206,7 @@ def main():
return

requests = read_json_many(data)
filtered_requests = filter_requests(requests, args.path_filters, args.get, args.sort)
filtered_requests = filter_requests(requests, args.path_filters, args.get, args.sort, args.unique)
if args.verbose:
print(
f"Read {len(data)} chars, {len(requests)} requests, {len(filtered_requests)} after filtering",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Deploying resources...
Updating deployment state...
Deployment complete!

>>> print_requests.py --get //vector-search/indexes
>>> print_requests.py --get --unique //vector-search/indexes

=== Change embedding_dimension (should trigger recreation)
>>> update_file.py databricks.yml embedding_dimension: 768 embedding_dimension: 384
Expand All @@ -27,7 +27,7 @@ Deploying resources...
Updating deployment state...
Deployment complete!

>>> print_requests.py --get //vector-search/indexes
>>> print_requests.py --get --unique //vector-search/indexes

>>> [CLI] vector-search-indexes get-index main.default.vs_index_[UNIQUE_NAME]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ print_requests() {
# without that, removing the wait would silently still pass against the
# testserver (which finishes deletion synchronously) — the GET in the log
# is the assertion that the wait actually fired.
trace print_requests.py --get '//vector-search/indexes' > out.requests.${name}.$DATABRICKS_BUNDLE_ENGINE.json
# --unique collapses the repeated identical poll GETs (one on the testserver,
# many on a real workspace that provisions asynchronously) to a stable count.
trace print_requests.py --get --unique '//vector-search/indexes' > out.requests.${name}.$DATABRICKS_BUNDLE_ENGINE.json
rm -f out.requests.txt
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Plan: 1 to add, 0 to change, 1 to delete, 1 unchanged
},
"endpoint_name": "vs-endpoint-[UNIQUE_NAME]",
"endpoint_uuid": "[UUID]",
"index_subtype": "HYBRID",
"index_type": "DIRECT_ACCESS",
"name": "main.default.vs_index_[UNIQUE_NAME]",
"primary_key": "id",
Expand All @@ -86,6 +87,11 @@ Plan: 1 to add, 0 to change, 1 to delete, 1 unchanged
"reason": "state-only field",
"old": "[UUID]",
"remote": "[UUID]"
},
"index_subtype": {
"action": "skip",
"reason": "backend_default",
"remote": "HYBRID"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions bundle/direct/dresources/resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,6 @@ resources:
reason: immutable
- field: direct_access_index_spec
reason: immutable
backend_defaults:
# The Vector Search API assigns index_subtype when the config omits it
- field: index_subtype
7 changes: 7 additions & 0 deletions libs/testserver/vector_search_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,18 @@ func (s *FakeWorkspace) VectorSearchIndexCreate(req Request) Response {
}
}

// The backend assigns index_subtype when the request omits it (HYBRID by default)
indexSubtype := createReq.IndexSubtype
if indexSubtype == "" {
indexSubtype = vectorsearch.IndexSubtypeHybrid
}

index := fakeVectorSearchIndex{
VectorIndex: vectorsearch.VectorIndex{
Creator: s.CurrentUser().UserName,
EndpointName: createReq.EndpointName,
IndexType: createReq.IndexType,
IndexSubtype: indexSubtype,
Name: createReq.Name,
PrimaryKey: createReq.PrimaryKey,
DeltaSyncIndexSpec: remapDeltaSyncSpec(createReq.DeltaSyncIndexSpec),
Expand Down
Loading