Skip to content

Commit a1e8899

Browse files
committed
Update deployment logic
1 parent 3191419 commit a1e8899

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

deploy_ai_search/ai_search.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,34 @@ def get_semantic_search(self) -> SemanticSearch:
128128
Returns:
129129
SemanticSearch: The semantic search configuration"""
130130

131-
@abstractmethod
132131
def get_skills(self) -> list:
133132
"""Get the skillset for the indexer.
134133
135134
Returns:
136135
list: The skillsets used in the indexer"""
137136

138-
@abstractmethod
137+
return []
138+
139139
def get_indexer(self) -> SearchIndexer:
140140
"""Get the indexer for the indexer."""
141141

142-
@abstractmethod
142+
return None
143+
143144
def get_index_projections(self) -> SearchIndexerIndexProjections:
144145
"""Get the index projections for the indexer."""
145146

147+
return None
148+
146149
def get_synonym_map_names(self) -> list[str]:
147150
"""Get the synonym map names for the indexer."""
148151
return []
149152

150153
def get_data_source(self) -> SearchIndexerDataSourceConnection:
151154
"""Get the data source for the indexer."""
152155

156+
if self.get_indexer() is None:
157+
return None
158+
153159
data_deletion_detection_policy = NativeBlobSoftDeleteDeletionDetectionPolicy()
154160

155161
data_change_detection_policy = HighWaterMarkChangeDetectionPolicy(
@@ -464,6 +470,12 @@ def deploy_index(self):
464470
def deploy_skillset(self):
465471
"""This function deploys the skillset."""
466472
skills = self.get_skills()
473+
474+
if len(skills) == 0:
475+
logging.warning("No skills defined. Skipping skillset deployment.")
476+
477+
return
478+
467479
index_projections = self.get_index_projections()
468480

469481
skillset = SearchIndexerSkillset(
@@ -481,6 +493,11 @@ def deploy_data_source(self):
481493
"""This function deploys the data source."""
482494
data_source = self.get_data_source()
483495

496+
if data_source is None:
497+
logging.warning("Data source not defined. Skipping data source deployment.")
498+
499+
return
500+
484501
result = self._search_indexer_client.create_or_update_data_source_connection(
485502
data_source
486503
)
@@ -491,6 +508,11 @@ def deploy_indexer(self):
491508
"""This function deploys the indexer."""
492509
indexer = self.get_indexer()
493510

511+
if indexer is None:
512+
logging.warning("Indexer not defined. Skipping data source deployment.")
513+
514+
return
515+
494516
result = self._search_indexer_client.create_or_update_indexer(indexer)
495517

496518
logging.info("%s indexer created", result.name)

deploy_ai_search/rag_documents.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ def __init__(
5252
self.enable_page_by_chunking = False
5353

5454
def get_index_fields(self) -> list[SearchableField]:
55-
"""This function returns the index fields for inquiry document.
55+
"""This function returns the index fields for rag document.
5656
5757
Returns:
58-
list[SearchableField]: The index fields for inquiry document"""
58+
list[SearchableField]: The index fields for rag document"""
5959

6060
fields = [
6161
SimpleField(name="Id", type=SearchFieldDataType.String, filterable=True),
@@ -114,7 +114,7 @@ def get_index_fields(self) -> list[SearchableField]:
114114
return fields
115115

116116
def get_semantic_search(self) -> SemanticSearch:
117-
"""This function returns the semantic search configuration for inquiry document
117+
"""This function returns the semantic search configuration for rag document
118118
119119
Returns:
120120
SemanticSearch: The semantic search configuration"""
@@ -178,7 +178,7 @@ def get_skills(self) -> list:
178178
return skills
179179

180180
def get_index_projections(self) -> SearchIndexerIndexProjections:
181-
"""This function returns the index projections for inquiry document."""
181+
"""This function returns the index projections for rag document."""
182182
mappings = [
183183
InputFieldMappingEntry(name="Chunk", source="/document/pages/*/chunk"),
184184
InputFieldMappingEntry(
@@ -221,10 +221,10 @@ def get_index_projections(self) -> SearchIndexerIndexProjections:
221221
return index_projections
222222

223223
def get_indexer(self) -> SearchIndexer:
224-
"""This function returns the indexer for inquiry document.
224+
"""This function returns the indexer for rag document.
225225
226226
Returns:
227-
SearchIndexer: The indexer for inquiry document"""
227+
SearchIndexer: The indexer for rag document"""
228228

229229
# Only place on schedule if it is not a test deployment
230230
if self.test:

0 commit comments

Comments
 (0)