Skip to content
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

[Search] Regenerate with 2024-03-01-Preview spec #28576

Merged
merged 13 commits into from
Mar 17, 2024

Conversation

dgetu
Copy link
Member

@dgetu dgetu commented Feb 14, 2024

Packages impacted by this PR

@azure/search-documents

Issues associated with this PR

Resolves #28299, #28300

Describe the problem that is addressed by this PR

It might be helpful to review this commit-by-commit through 41c3338

What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?

Are there test cases added in this PR? (If not, why?)

Provide a list of related PRs (if any)

Command used to generate this PR:**(Applicable only to SDK release request PRs)

Checklists

  • Added impacted package name to the issue description
  • Added a changelog (if necessary)

See #28772 for more info on the last commit and title

@dgetu dgetu force-pushed the search/catch-beta-up-to-ga-12 branch 7 times, most recently from fe1e6de to 658ac19 Compare February 17, 2024 20:48
@dgetu dgetu marked this pull request as ready for review February 18, 2024 03:11
@dgetu dgetu requested review from bterlson, xirzec, jeremymeng and a team as code owners February 18, 2024 03:11
Copy link
Member

@maorleger maorleger left a comment

Choose a reason for hiding this comment

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

Unfortunately wasn't able to complete reviewing, but there's a lot I like about it 😄

There are some concerns I have regarding the types and breaking changes - happy to discuss!

sdk/search/search-documents/.eslintrc.json Show resolved Hide resolved
@@ -1,3 +1,3 @@
{
"cSpell.words": ["hnsw", "openai"]
"cSpell.words": ["hnsw", "openai", "Vectorizer"]
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can we move this to https://github.com/maorleger/azure-sdk-for-js/blob/main/.vscode/cspell.json and keep all the cspell in the same place?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, these actually belong in .vscode/cspell.json, so I'll move those over.

sdk/search/search-documents/CHANGELOG.md Show resolved Hide resolved
sdk/search/search-documents/README.md Show resolved Hide resolved
@@ -27,12 +28,12 @@ export interface AnalyzedTokenInfo {

// @public
export interface AnalyzeRequest {
analyzerName?: string;
charFilters?: string[];
analyzerName?: LexicalAnalyzerName;
Copy link
Member

Choose a reason for hiding this comment

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

Ignore me if these are all aliases to string, but if they are unions or some other narrower type this would be a breaking change?

I won't comment on every change here yet but we should not have breaking changes in a minor release so please do validate that 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Some of these changes are just named string aliases, some of them are string literal unions where they're output-only parameters. But only purportedly. I mentioned this elsewhere, but it's probably not worth the maintenance burden to manually track down which extensible enums are output-only, and I'd have to think about whether or not it's worth making a Swagger parser to automate this.

@@ -232,77 +237,67 @@ export interface BaseVectorSearchVectorizer {
}

// @public
export type BlobIndexerDataToExtract = string;
export type BlobIndexerDataToExtract = "storageMetadata" | "allMetadata" | "contentAndMetadata";
Copy link
Member

Choose a reason for hiding this comment

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

Like here, if these are input params then this would be a breaking change. If they are output only then I think it's fine

Copy link
Member Author

Choose a reason for hiding this comment

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

I intended for only output parameters to have custom string literal unions, but I think I might be creating too much of a maintenance burden here. Without proper tooling to help determine what types are output-only, and to catch when an output only type is consumed in a later revision, it's probably too much effort to maintain this convenience.

We're hoping to iron out our extensible enum plans over the coming weeks. Until then, I'm thinking I'll revert these where I can. But there's a not insignificant chance that I've already introduced a string literal union where it doesn't belong in the last GA release. Lots of bugs to squash there.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a script to generate diffs against the upstream stable and main (preview) branches for the API Extractor output. Any unified diff GUI/TUI should be able to render those files (under the review dir), but any hunks that don't modify/remove any lines are omitted since they're ostensibly just new features. There are some spurious errors in there though (the difftool removes a line in one hunk and adds an identical line in another).

In the same commit, there's a script to generate string literal unions from TS files with enum declarations. Again, spurious errors, but nothing too difficult to manually check/correct.

Hopefully, these changes will make it a bit easier to assess where the API surface diverges and speeds up feature development moving forward. I'll need to make a runbook though; this is getting a bit too complex not to have documentation.

@@ -76,7 +76,7 @@ export async function main() {
console.log(response);
});

bufferedClient.uploadDocuments([
await bufferedClient.uploadDocuments([
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, i'm starting to like the idea of linting our samples-dev files as well

@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

@azure/search-documents

@dgetu dgetu force-pushed the search/catch-beta-up-to-ga-12 branch from c9cc71a to 5a1f38d Compare March 9, 2024 04:52
@@ -44,31 +45,10 @@ export interface AnalyzeResult {
export type AnalyzeTextOptions = OperationOptions & AnalyzeRequest;

// @public
export interface AnswerResult {
Copy link
Member

Choose a reason for hiding this comment

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

Did these get moved or no longer needed? I guess why are they missing and is that expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

They were renamed to QueryAnswer and QueryCaption.

@@ -2189,6 +2294,7 @@ export class SearchClient<TModel extends object> implements IndexDocumentsClient
readonly indexName: string;
mergeDocuments(documents: TModel[], options?: MergeDocumentsOptions): Promise<IndexDocumentsResult>;
mergeOrUploadDocuments(documents: TModel[], options?: MergeOrUploadDocumentsOptions): Promise<IndexDocumentsResult>;
readonly pipeline: Pipeline;
Copy link
Member

Choose a reason for hiding this comment

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

did we mean to expose the pipeline here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. The service is moving fast, so we're exposing the pipeline to allow customers to send raw requests with our HTTP pipeline. It's called out in the changelog.

@@ -0,0 +1,29 @@
#!/usr/bin/env -S perl -i

use Algorithm::Combinatorics qw(variations_with_repetition);
Copy link
Member

Choose a reason for hiding this comment

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

what is this for, and why not use JavaScript? 😈

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a small script to save me some time while hand-editing the typeDefinitions.ts test files. It just renames every const variable declaration with sequential strings. There's more that I intended to automate in that space, but I think I either lost some of that progress in a Codespace rebuild or otherwise shelved that for other priorities.

As for why it's Perl, I find that text file manipulation is a bit more idiomatic. perl -i modifies files in-place, so it's common to find Perl one-liners in the form perl -i -pe 's/foo/bar/msg' foo.txt (replaces all occurrences of foo with bar).

Copy link
Member

Choose a reason for hiding this comment

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

FWIW we used to have a small .js build script for EventGrid that did some massaging of types. I think in general it'd be good to stick to JS/TS when possible so you can hand it off to other maintainers more easily.

@dgetu dgetu force-pushed the search/catch-beta-up-to-ga-12 branch 2 times, most recently from d292cc6 to 0cf5c76 Compare March 14, 2024 08:27
@dgetu dgetu force-pushed the search/catch-beta-up-to-ga-12 branch from 0cf5c76 to 0199a1d Compare March 17, 2024 00:40
@dgetu dgetu requested a review from witemple-msft as a code owner March 17, 2024 00:40
@dgetu dgetu force-pushed the search/catch-beta-up-to-ga-12 branch from 0199a1d to f65827e Compare March 17, 2024 01:50
@dgetu dgetu changed the title [Search] Apply v12 API changes to preview [Search] Regenerate with 2024-03-01-Preview spec Mar 17, 2024
@dgetu dgetu force-pushed the search/catch-beta-up-to-ga-12 branch from ef34ff6 to f55a190 Compare March 17, 2024 05:55
@dgetu dgetu force-pushed the search/catch-beta-up-to-ga-12 branch from f55a190 to b45bd2a Compare March 17, 2024 06:10
@dgetu dgetu force-pushed the search/catch-beta-up-to-ga-12 branch from b45bd2a to b2c22d9 Compare March 17, 2024 06:39
@dgetu dgetu enabled auto-merge (squash) March 17, 2024 06:54
@dgetu dgetu merged commit d738efb into Azure:main Mar 17, 2024
14 checks passed
@dgetu dgetu linked an issue Mar 25, 2024 that may be closed by this pull request
@dgetu dgetu linked an issue Apr 30, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
4 participants