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

Updated template and job creation for scrapers and indexers #1072

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
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
73 changes: 43 additions & 30 deletions config_generation/db_to_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,35 +148,51 @@ def convert_template_to_scraper(self, collection) -> None:
scraper_config = self.update_config_xml()
return scraper_config

def convert_template_to_plugin_indexer(self, scraper_editor) -> None:
def convert_template_to_job(self, collection, job_source) -> None:
"""
assuming this class has been instantiated with the scraper_template.xml
assuming this class has been instantiated with the job_template.xml
"""
self.update_or_add_element_value("Collection", f"/{job_source}/{collection.config_folder}/")
job_config = self.update_config_xml()
return job_config

def convert_template_to_indexer(self, scraper_editor) -> None:
"""
assuming this class has been instantiated with the final_config_template.xml
"""

transfer_fields = [
"KeepHashFragmentInUrl",
"CorrectDomainCookies",
"IgnoreSessionCookies",
"DownloadImages",
"DownloadMedia",
"DownloadCss",
"DownloadFtp",
"DownloadFile",
"IndexJs",
"FollowJs",
"CrawlFlash",
"NormalizeSecureSchemesWhenTestingVisited",
"RetryCount",
"RetryPause",
"AddBaseHref",
"AddMetaContentType",
"NormalizeUrls",
"Throttle",
]

double_transfer_fields = [
("UrlAccess", "AllowXPathCookies"),
("UrlAccess", "UseBrowserForWebRequests"),
("UrlAccess", "UseHttpClientForWebRequests"),
("UrlAccess", "BrowserForWebRequestsReadinessThreshold"),
("UrlAccess", "BrowserForWebRequestsInitialDelay"),
("UrlAccess", "BrowserForWebRequestsMaxTotalDelay"),
("UrlAccess", "BrowserForWebRequestsMaxResourcesDelay"),
("UrlAccess", "BrowserForWebRequestsLogLevel"),
("UrlAccess", "BrowserForWebRequestsViewportWidth"),
("UrlAccess", "BrowserForWebRequestsViewportHeight"),
("UrlAccess", "BrowserForWebRequestsAdditionalJavascript"),
("UrlAccess", "PostLoginUrl"),
("UrlAccess", "PostLoginData"),
("UrlAccess", "GetBeforePostLogin"),
("UrlAccess", "PostLoginAutoRedirect"),
("UrlAccess", "ReLoginCount"),
("UrlAccess", "ReLoginDelay"),
("UrlAccess", "DetectHtmlLoginPattern"),
("IndexerClient", "RetryTimeout"),
("IndexerClient", "RetrySleep"),
]

triple_transfer_fields = [
("UrlAccess", "BrowserLogin", "Activate"),
("UrlAccess", "BrowserLogin", "RemoteDebuggingPort"),
("UrlAccess", "BrowserLogin", "BrowserLogLevel"),
("UrlAccess", "BrowserLogin", "ShowDevTools"),
("UrlAccess", "BrowserLogin", "SuccessCondition"),
("UrlAccess", "BrowserLogin", "CookieFilter"),
]

for field in transfer_fields:
Expand All @@ -187,18 +203,15 @@ def convert_template_to_plugin_indexer(self, scraper_editor) -> None:
f"{parent}/{child}", scraper_editor.get_tag_value(f"{parent}/{child}", strict=True)
)

for grandparent, parent, child in triple_transfer_fields:
self.update_or_add_element_value(
f"{grandparent}/{parent}/{child}",
scraper_editor.get_tag_value(f"{grandparent}/{parent}/{child}", strict=True),
)

scraper_config = self.update_config_xml()
return scraper_config

def convert_template_to_indexer(self, collection) -> None:
"""
assuming this class has been instantiated with the indexer_template.xml
"""
self.update_or_add_element_value("Collection", f"/SDE/{collection.config_folder}/")
indexer_config = self.update_config_xml()

return indexer_config

def _mapping_exists(self, new_mapping: ET.Element):
"""
Check if the mapping with given parameters already exists in the XML tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
<indexers></indexers>
<index></index>
<domain></domain>
<treeRoot></treeRoot>
<Revision>1</Revision>
<visibility></visibility>
<ForceReindexation>false</ForceReindexation>
<Url></Url>
<Plugin>SMD_Plugins/Sinequa.Plugin.WebCrawler_Index_URLList</Plugin>
<WorkerCount>6</WorkerCount>
<WorkerCount>3</WorkerCount>
<MaxWorkerPerHost></MaxWorkerPerHost>
<UrlList></UrlList>
<DynamicUrlList></DynamicUrlList>
Expand All @@ -23,23 +25,36 @@
<EnableNeuralIndexing>true</EnableNeuralIndexing>
<NeuralSearchSelectionQuery></NeuralSearchSelectionQuery>
<UrlStayInside>true</UrlStayInside>
<UrlRefererStayInside>false</UrlRefererStayInside>
<FollowLinks>false</FollowLinks>
<MaxLevel>100</MaxLevel>
<MaxToIndex>100000</MaxToIndex>
<MaxToCrawl>100000</MaxToCrawl>
<MaxRedirection>10</MaxRedirection>
<CrawlMaxSize>-1</CrawlMaxSize>
<CrawlTimeout>-1</CrawlTimeout>
<MaxLevel></MaxLevel>
<MaxToIndex></MaxToIndex>
<MaxToCrawl></MaxToCrawl>
<MaxRedirection></MaxRedirection>
<CrawlMaxSize></CrawlMaxSize>
<CrawlTimeout></CrawlTimeout>
<NormalizeUrls>true</NormalizeUrls>
<CorrectDomainCookies>false</CorrectDomainCookies>
<IgnoreSessionCookies>false</IgnoreSessionCookies>
<DownloadImages>true</DownloadImages>
<DownloadMedia>true</DownloadMedia>
<DownloadCss>false</DownloadCss>
<DownloadFtp>true</DownloadFtp>
<DownloadFile>true</DownloadFile>
<IndexJs>false</IndexJs>
<FollowJs>true</FollowJs>
<CrawlFlash>true</CrawlFlash>
<IndexEmptyPages>true</IndexEmptyPages>
<CrawlWebsphereSeedlist>true</CrawlWebsphereSeedlist>
<KeepHashFragmentInUrl>false</KeepHashFragmentInUrl>
<RetryCount></RetryCount>
<RetryPause></RetryPause>
<HttpCodesToRetry></HttpCodesToRetry>
<UseIfModifiedSince>true</UseIfModifiedSince>
<UseIfNoneMatch>no</UseIfNoneMatch>
<AcceptWeakETag>false</AcceptWeakETag>
<ForcedEncoding></ForcedEncoding>
<UseCompression>false</UseCompression>
<UseUnsafeHeaderParsing>false</UseUnsafeHeaderParsing>
<NormalizeSecureSchemesWhenTestingVisited>false</NormalizeSecureSchemesWhenTestingVisited>
<ExactDeduplication>false</ExactDeduplication>
<NearDeduplication>false</NearDeduplication>
<CrawlPauseDelay></CrawlPauseDelay>
Expand All @@ -49,7 +64,7 @@
<RememberConnectFailure>true</RememberConnectFailure>
<RememberTrustFailure>true</RememberTrustFailure>
<RememberProxyNameResolutionFailure>false</RememberProxyNameResolutionFailure>
<UseRobotsNoIndex>true</UseRobotsNoIndex>
<UseRobotsNoIndex>false</UseRobotsNoIndex>
<UseRobotsNoFollow>true</UseRobotsNoFollow>
<UseRobotsTxt>false</UseRobotsTxt>
<RobotsTxtCaseSensitive>false</RobotsTxtCaseSensitive>
Expand Down Expand Up @@ -83,14 +98,16 @@
<ClientCertificateStorage></ClientCertificateStorage>
<AllowXPathCookies>false</AllowXPathCookies>
<UseHttpClientForWebRequests>false</UseHttpClientForWebRequests>
<UseBrowserForWebRequests>true</UseBrowserForWebRequests>
<ThrottleManagerCode>expBackoff+headers</ThrottleManagerCode>
<UseBrowserForWebRequests>false</UseBrowserForWebRequests>
<BrowserForWebRequestsReadinessThreshold></BrowserForWebRequestsReadinessThreshold>
<BrowserForWebRequestsInitialDelay></BrowserForWebRequestsInitialDelay>
<BrowserForWebRequestsMaxTotalDelay></BrowserForWebRequestsMaxTotalDelay>
<BrowserForWebRequestsMaxResourcesDelay></BrowserForWebRequestsMaxResourcesDelay>
<BrowserForWebRequestsLogLevel></BrowserForWebRequestsLogLevel>
<BrowserForWebRequestsViewportWidth></BrowserForWebRequestsViewportWidth>
<BrowserForWebRequestsViewportHeight></BrowserForWebRequestsViewportHeight>
<BrowserForWebRequestsAdditionalJavascript></BrowserForWebRequestsAdditionalJavascript>
<WebConnectionPluginName></WebConnectionPluginName>
<PostLoginUrl></PostLoginUrl>
<PostLoginData></PostLoginData>
Expand All @@ -103,6 +120,7 @@
<Activate>false</Activate>
<RemoteDebuggingPort></RemoteDebuggingPort>
<BrowserLogLevel></BrowserLogLevel>
<ShowDevTools>false</ShowDevTools>
<SuccessCondition></SuccessCondition>
<CookieFilter></CookieFilter>
</BrowserLogin>
Expand All @@ -128,15 +146,15 @@
<ProxyAddress></ProxyAddress>
<ProxyBypassOnLocal>true</ProxyBypassOnLocal>
<ProxyServer></ProxyServer>
<ProxyPort>80</ProxyPort>
<ProxyPort></ProxyPort>
<ProxyUseDefaultCredentials>true</ProxyUseDefaultCredentials>
<ProxyUseDefaultNetworkCredentials>false</ProxyUseDefaultNetworkCredentials>
<ProxyUser></ProxyUser>
<ProxyPassword></ProxyPassword>
<ProxyDomain></ProxyDomain>
</UrlAccess>
<System>
<LogLevel>20</LogLevel>
<LogLevel>INFO</LogLevel>
</System>
<DisplayLongProperties>false</DisplayLongProperties>
<LongPropertyLimit></LongPropertyLimit>
Expand All @@ -149,39 +167,32 @@
<SaveDeniedDocs>false</SaveDeniedDocs>
<SavePropertiesToRegistry>false</SavePropertiesToRegistry>
<CollectionStateNative>false</CollectionStateNative>
<HtmlNavigatorNative>false</HtmlNavigatorNative>
<HtmlNavigatorNative>true</HtmlNavigatorNative>
<XPathNavigatorNative>false</XPathNavigatorNative>
<StatusMaxOk></StatusMaxOk>
<DelApiSecret></DelApiSecret>
<IndexerClient>
<Simulate>false</Simulate>
<SimulateGetCollectionState>false</SimulateGetCollectionState>
<QueueMaxCount></QueueMaxCount>
<SendingThreadFactor></SendingThreadFactor>
<DirectFileAccess>false</DirectFileAccess>
<UseCompression>false</UseCompression>
<SessionIsFinishedWait>false</SessionIsFinishedWait>
<SendTimeout></SendTimeout>
<ReceiveTimeout></ReceiveTimeout>
<RetryConnectCount></RetryConnectCount>
<RetryConnectDelay></RetryConnectDelay>
<SleepQueueFull></SleepQueueFull>
<SleepQueueFullCount></SleepQueueFullCount>
<SleepQueueFullQuick></SleepQueueFullQuick>
<SleepQueueFullQuickCount></SleepQueueFullQuickCount>
<SleepCheckOpen></SleepCheckOpen>
<SleepCheckOpenCount></SleepCheckOpenCount>
<SleepCheckOpenQuick></SleepCheckOpenQuick>
<SleepCheckOpenQuickCount></SleepCheckOpenQuickCount>
<RetryTimeout></RetryTimeout>
<RetrySleep></RetrySleep>
<DeactivationTimeout></DeactivationTimeout>
<BackToSendingQueueCount></BackToSendingQueueCount>
</IndexerClient>
<Indexation>
<SimulateLemma>false</SimulateLemma>
<SimulateEngine>false</SimulateEngine>
<SimulateCache>false</SimulateCache>
<SimulateLemmaMin></SimulateLemmaMin>
<SimulateLemmaMax></SimulateLemmaMax>
<CollectionStateParallelRowFetch>0</CollectionStateParallelRowFetch>
<CollectionStateParallelRowFetch></CollectionStateParallelRowFetch>
<EngineMetaEnabled>true</EngineMetaEnabled>
<ThumbnailHeight></ThumbnailHeight>
<ThumbnailWidth></ThumbnailWidth>
Expand All @@ -192,6 +203,7 @@
<StoreInCollectionCache>false</StoreInCollectionCache>
<GetFilePropertiesFromConverter>false</GetFilePropertiesFromConverter>
</Indexation>
<CollectDocumentProperties>true</CollectDocumentProperties>
<DocCountLimitOnCollectProperties></DocCountLimitOnCollectProperties>
<ForceBlobSend>false</ForceBlobSend>
<ContinueOnError>true</ContinueOnError>
Expand All @@ -209,6 +221,8 @@
<RealTimeInfoOnError>false</RealTimeInfoOnError>
<ConversionProxies></ConversionProxies>
<ConversionPlan></ConversionPlan>
<AddBaseHref>true</AddBaseHref>
<AddMetaContentType>false</AddMetaContentType>
<Throttle></Throttle>
<DocumentClass></DocumentClass>
<ConnectorLanguage></ConnectorLanguage>
Expand Down Expand Up @@ -242,6 +256,7 @@
<ArchiveItemsUseArchiveVersion>false</ArchiveItemsUseArchiveVersion>
<UseShortAttachmentId>false</UseShortAttachmentId>
<UseExtendedExtensionGuesser>false</UseExtendedExtensionGuesser>
<AlwaysScanContainerFiles>false</AlwaysScanContainerFiles>
<XmpExtensions></XmpExtensions>
<MediaExtensions></MediaExtensions>
<ExiftoolExtensions></ExiftoolExtensions>
Expand All @@ -250,6 +265,7 @@
<AttachmentSelectionQuery></AttachmentSelectionQuery>
<ArchiveItemSelectionQuery></ArchiveItemSelectionQuery>
<EngineConnectionWait></EngineConnectionWait>
<FetchCollectionDataDirectlyFromEngine></FetchCollectionDataDirectlyFromEngine>
<CalculateGraphBoost>false</CalculateGraphBoost>
<GraphBoostColumn></GraphBoostColumn>
<GraphBoostEMColumn></GraphBoostEMColumn>
Expand All @@ -268,4 +284,6 @@
<Name>id</Name>
<Value>doc.url1</Value>
</Mapping>
<UrlRefererStayInside>false</UrlRefererStayInside>
<FollowLinks>false</FollowLinks>
</Sinequa>
Loading
Loading