-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
code refactoring 4 #11800
code refactoring 4 #11800
Conversation
* [HDInsight] Fix hdi test failure (#11806) * Initial generation Synapse autorest v5 * Fix empty model generation * Fix Test Failure: Skip 3 test case: test_create_with_adlsgen1, test_create_with_additional_storage, test_oms_on_running_cluster Rename test_http_extend to test_gateway_setting for http settings is replaced with gateway settings Co-authored-by: Laurent Mazuel <laurent.mazuel@gmail.com> Co-authored-by: Zhenyu Zhou <zhezhou@microsoft.com> * disable some by design bandit warnings (#11495) * disable some by design bandit warnings * Packaging update of azure-mgmt-datalake-analytics Co-authored-by: Azure SDK Bot <aspysdk2@microsoft.com> * Increment package version after release of azure_core (#11795) * Use subject claim as home_account_id when no client_info (#11639) * Refactor ClientCertificateCredential to use AadClient (#11719) * Refactor ClientSecretCredential to use AadClient (#11718) * [Cosmos] Fixed incorrect ID type error (#11798) * Fixed incorrect ID type error * Fix pylint * [text analytics] Update readme (#11796) * try something (#11797) * Search refactoring 3 (#11804) * create_or_update takes object * rename is_hidden to hidden * fix types * updates Co-authored-by: aim-for-better <zhenyu.zhou@microsoft.com> Co-authored-by: Laurent Mazuel <laurent.mazuel@gmail.com> Co-authored-by: Zhenyu Zhou <zhezhou@microsoft.com> Co-authored-by: Azure SDK Bot <aspysdk2@microsoft.com> Co-authored-by: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Co-authored-by: Charles Lowell <chlowe@microsoft.com> Co-authored-by: annatisch <antisch@microsoft.com> Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Co-authored-by: Krista Pratico <krpratic@microsoft.com>
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.
A model still needs renaming (see comments), but I'll sign off to keep you unblocked.
@@ -235,7 +235,7 @@ def create_or_update_index( | |||
|
|||
@distributed_trace | |||
def analyze_text(self, index_name, analyze_request, **kwargs): | |||
# type: (str, AnalyzeRequest, **Any) -> AnalyzeResult | |||
# type: (str, AnalyzeTextRequest, **Any) -> AnalyzeResult |
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.
Should be AnalyzeTextOptions
now, or was that going to come in a separate PR? See #11830.
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.
Already fixed. :)
/azp run python - search - ci |
1 similar comment
/azp run python - search - ci |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run python - search - ci |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
This all looks good with my limited understanding of our Python best practices. 😄
include_total_result_count = kwargs.pop("include_total_result_count", None) | ||
facets = kwargs.pop("facets", None) | ||
filter_arg = kwargs.pop("filter", None) | ||
highlight_fields = kwargs.pop("highlight_fields", None) | ||
highlight_post_tag = kwargs.pop("highlight_post_tag", None) | ||
highlight_pre_tag = kwargs.pop("highlight_pre_tag", None) | ||
minimum_coverage = kwargs.pop("minimum_coverage", None) | ||
order_by = kwargs.pop("order_by", None) | ||
query_type = kwargs.pop("query_type", None) | ||
scoring_parameters = kwargs.pop("scoring_parameters", None) | ||
scoring_profile = kwargs.pop("scoring_profile", None) | ||
search_fields = kwargs.pop("search_fields", None) | ||
search_mode = kwargs.pop("search_mode", None) | ||
select = kwargs.pop("select", None) | ||
skip = kwargs.pop("skip", None) | ||
top = kwargs.pop("top", None) | ||
query = SearchQuery( | ||
search_text=search_text, | ||
include_total_result_count=include_total_result_count, | ||
facets=facets, | ||
filter=filter_arg, | ||
highlight_fields=highlight_fields, | ||
highlight_post_tag=highlight_post_tag, | ||
highlight_pre_tag=highlight_pre_tag, | ||
minimum_coverage=minimum_coverage, | ||
order_by=order_by, | ||
query_type=query_type, | ||
scoring_parameters=scoring_parameters, | ||
scoring_profile=scoring_profile, | ||
search_fields=search_fields, | ||
search_mode=search_mode, | ||
select=select, | ||
skip=skip, | ||
top=top | ||
) |
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.
Nit - Is it worth moving this logic onto the SearchQuery class so you don't have to update both the sync/async clients whenever we add a new parameter? I'm not sure how the Python folks typically handle these situations. (Also, we can just file a work item rather for Preview 5 rather than try to fix it today.)
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.
SearchQuery and AutocompleteQuery, SuggestQuery share one ctor. If we put all of pop operation there, I am afraid it will be messed up.
): | ||
super(AnalyzeTextOptions, self).__init__(**kwargs) | ||
self.text = kwargs['text'] | ||
self.analyzer_name = kwargs.get('analyzer_name', None) |
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.
Just for my own understanding - why get
here vs pop
in search when taking apart kwargs?
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.
The difference is pop will remove the argument from kwargs. In init method, kwargs will not be used in anywhere else so there is no difference. But in e.g. search method, if I don't pop them, those arguments will be passed into transport which will cause problems.
async with search_client: | ||
results = await search_client.search(query=query) | ||
results = await search_client.search(search_text="WiFi", facets=["Category"], top=0) |
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.
This looks very nice.
client = SearchIndexClient(endpoint="<service endpoint>" | ||
credential=credential) |
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.
client = SearchIndexClient(endpoint="<service endpoint>" | |
credential=credential) | |
client = SearchIndexClient(endpoint="<service endpoint>", | |
credential=credential) |
@@ -64,18 +65,33 @@ client = SearchClient(endpoint="<service endpoint>", | |||
credential=credential) | |||
``` | |||
|
|||
#### Create a SearchServiceClient | |||
#### Create a SearchIndexClient | |||
|
|||
Once you have the values of the Cognitive Search Service [service endpoint](https://docs.microsoft.com/en-us/azure/search/search-create-service-portal#get-a-key-and-url-endpoint) | |||
and [api key](https://docs.microsoft.com/en-us/azure/search/search-security-api-keys) you can create the Search Service client: |
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.
and [api key](https://docs.microsoft.com/en-us/azure/search/search-security-api-keys) you can create the Search Service client: | |
and [api key](https://docs.microsoft.com/en-us/azure/search/search-security-api-keys) you can create the Search Index client: |
#### Create a SearchIndexerClient | ||
|
||
Once you have the values of the Cognitive Search Service [service endpoint](https://docs.microsoft.com/en-us/azure/search/search-create-service-portal#get-a-key-and-url-endpoint) | ||
and [api key](https://docs.microsoft.com/en-us/azure/search/search-security-api-keys) you can create the Search Service client: |
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.
and [api key](https://docs.microsoft.com/en-us/azure/search/search-security-api-keys) you can create the Search Service client: | |
and [api key](https://docs.microsoft.com/en-us/azure/search/search-security-api-keys) you can create the Search Indexer client: |
|
||
credential = AzureKeyCredential("<api key>") | ||
|
||
client = SearchIndexerClient(endpoint="<service endpoint>" |
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.
client = SearchIndexerClient(endpoint="<service endpoint>" | |
client = SearchIndexerClient(endpoint="<service endpoint>", |
"""Search the Azure search index for documents. | ||
|
||
:param query: An query for searching the index | ||
:type documents: str or SearchQuery | ||
:param str search_text: A full-text search query expression; Use "*" or omit this parameter to |
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.
by omit this parameter - do you mean search_text is optional? If not, is it by design to not make it optional and use '*' as default value.
#11799