Skip to content

Conversation

@BrendanWalsh
Copy link
Collaborator

Related Issues/PRs

Fixes broken build and tests caused by the retirement of Bing Search API v7.

What changes are proposed in this pull request?

Briefly describe the changes included in this Pull Request.

This PR removes all dependencies on the deprecated BingImageSearch and BingSearchAPIWrapper components, which are no longer functional following the retirement of the Bing Search API v7.

Key Changes:

  • Removed Components: Deleted BingImageSearch (Scala & Python), ImageSearchSuite, and BingSearchAPIWrapper references.
  • Refactored Notebooks:
    • Quickstart - Snow Leopard Detection.ipynb: Replaced dynamic Bing Search with a static dataset of snow leopard images. Implemented a custom download_bytes UDF to replace the BingImageSearch downloader.
    • Quickstart - Analyze Celebrity Quotes.ipynb: Replaced Bing Search query with a static list of celebrity image URLs.
  • Refactored Tests:
    • Updated FormRecognizerSuite, ComputerVisionSuite, OCRSuite, and others to remove BingImageSearch dependency.
    • Introduced a shared VisionUtils trait with a downloadBytes UDF to handle image downloading for tests, ensuring they remain deterministic and fast.

How is this patch tested?

  • I have written tests (not required for typo or doc fix) and confirmed the proposed feature/bug-fix/change works.

Verification Steps:

  1. Compilation: Verified that all refactored test suites (FormRecognizerSuite, ComputerVisionSuite, etc.) compile successfully.
  2. Test Execution: Ran sbt "testOnly *FormRecognizerSuite *ComputerVisionSuite" to confirm the new static data approach works as expected.
  3. Notebook Verification: Manually verified that the refactored notebooks are syntactically correct and free of legacy bing-search-key references.
  4. Cleanliness: Confirmed via grep that no references to BingImageSearch or bing-search-key remain in the active codebase.

Does this PR change any dependencies?

  • No. You can skip this section.
  • Yes. Make sure the dependencies are resolved correctly, and list changes here.

Removed internal dependencies on BingImageSearch and external calls to Bing Search API.

Does this PR add a new feature? If so, have you added samples on website?

  • No. You can skip this section.
  • Yes. Make sure you have added samples following below steps.

@BrendanWalsh BrendanWalsh requested a review from Copilot November 25, 2025 01:06
@github-actions
Copy link

Hey @BrendanWalsh 👋!
Thank you so much for contributing to our repository 🙌.
Someone from SynapseML Team will be reviewing this pull request soon.

We use semantic commit messages to streamline the release process.
Before your pull request can be merged, you should make sure your first commit and PR title start with a semantic prefix.
This helps us to create release messages and credit you for your hard work!

Examples of commit messages with semantic prefixes:

  • fix: Fix LightGBM crashes with empty partitions
  • feat: Make HTTP on Spark back-offs configurable
  • docs: Update Spark Serving usage
  • build: Add codecov support
  • perf: improve LightGBM memory usage
  • refactor: make python code generation rely on classes
  • style: Remove nulls from CNTKModel
  • test: Add test coverage for CNTKModel

To test your commit locally, please follow our guild on building from source.
Check out the developer guide for additional guidance on testing your change.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the deprecated BingImageSearch and related components following the retirement of Bing Search API v7. The removal includes Scala and Python implementations, test files, and associated schemas. Tests that previously relied on BingImageSearch for downloading images have been refactored to use a new downloadBytes utility function with static datasets.

Key Changes:

  • Removed deprecated Bing Search components (BingImageSearch, ImageSearchSchemas, ImageSearchSuite)
  • Introduced VisionUtils and enhanced FormRecognizerUtils traits with downloadBytes functionality to replace BingImageSearch download capabilities
  • Refactored test suites to use direct HTTP downloads instead of the deprecated BingImageSearch API

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
core/src/test/scala/com/microsoft/azure/synapse/ml/Secrets.scala Removed BingSearchKey secret reference
core/src/main/scala/com/microsoft/azure/synapse/ml/logging/FeatureNames.scala Removed BingImage feature name from AI Services
cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/vision/ComputerVisionSuite.scala Added VisionUtils trait with downloadBytes functionality; refactored all vision test suites to use new download approach
cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/form/FormRecognizerSuite.scala Added downloadBytes utility to FormRecognizerUtils; simplified createTestDataframe with default parameter
cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/bing/ImageSearchSuite.scala Deleted entire test suite for deprecated BingImageSearch
cognitive/src/main/scala/com/microsoft/azure/synapse/ml/services/bing/ImageSearchSchemas.scala Deleted schema definitions for BingImageSearch API
cognitive/src/main/scala/com/microsoft/azure/synapse/ml/services/bing/BingImageSearch.scala Deleted main BingImageSearch implementation
cognitive/src/main/python/synapse/ml/services/bing/BingImageSearch.py Deleted Python wrapper for BingImageSearch

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}



Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

[nitpick] Excessive whitespace: Multiple blank lines (2) before override def testObjects(). Consider reducing to a single blank line to maintain consistency.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +103 to +110
def downloadBytes(url: String): Array[Byte] = {
val request = new HttpGet(url)
using(RESTHelpers.Client.execute(request)) { response =>
IOUtils.toByteArray(response.getEntity.getContent)
}.get
}

val downloadBytesUdf = udf(downloadBytes _)
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

Code duplication: The downloadBytes function and downloadBytesUdf are defined identically in both VisionUtils trait (ComputerVisionSuite.scala) and FormRecognizerUtils trait (FormRecognizerSuite.scala). Consider extracting this into a shared test utility trait to avoid duplication and ensure consistency.

Copilot uses AI. Check for mistakes.
Comment on lines 19 to 29

import com.microsoft.azure.synapse.ml.services.CognitiveKey

trait VisionUtils extends TestBase {
import spark.implicits._

def downloadBytes(url: String): Array[Byte] = {
val request = new HttpGet(url)
using(RESTHelpers.Client.execute(request)) { response =>
IOUtils.toByteArray(response.getEntity.getContent)
}.get
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

[nitpick] Error handling: The .get call on the Try returned by using will throw an exception if the HTTP request or byte array conversion fails. Consider adding explicit error handling or documenting that test failures due to network issues are expected, especially since this replaces the previous BingImageSearch.downloadFromUrls which may have had retry logic.

Suggested change
import com.microsoft.azure.synapse.ml.services.CognitiveKey
trait VisionUtils extends TestBase {
import spark.implicits._
def downloadBytes(url: String): Array[Byte] = {
val request = new HttpGet(url)
using(RESTHelpers.Client.execute(request)) { response =>
IOUtils.toByteArray(response.getEntity.getContent)
}.get
import org.apache.log4j.Logger
import com.microsoft.azure.synapse.ml.services.CognitiveKey
trait VisionUtils extends TestBase {
import spark.implicits._
// Downloads bytes from a URL. If the download fails (e.g., due to network issues),
// logs a warning and returns an empty array. Test failures due to network issues are possible.
private val logger = Logger.getLogger(getClass)
def downloadBytes(url: String): Array[Byte] = {
val request = new HttpGet(url)
val result = util.Try {
using(RESTHelpers.Client.execute(request)) { response =>
IOUtils.toByteArray(response.getEntity.getContent)
}
}
result match {
case util.Success(bytes) => bytes
case util.Failure(e) =>
logger.warn(s"Failed to download bytes from $url: ${e.getMessage}")
Array.emptyByteArray
}

Copilot uses AI. Check for mistakes.
Comment on lines 208 to 210



Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

[nitpick] Excessive whitespace: Multiple blank lines (4) before override def testObjects(). Consider reducing to a single blank line to maintain consistency with other test suites in the codebase (e.g., FaceSuite.scala, AnomalyDetectionSuite.scala).

Suggested change

Copilot uses AI. Check for mistakes.
}



Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

[nitpick] Excessive whitespace: Multiple blank lines (2) before override def testObjects(). Consider reducing to a single blank line to maintain consistency.

Suggested change

Copilot uses AI. Check for mistakes.
BrendanWalsh and others added 5 commits November 24, 2025 22:33
…es/form/FormRecognizerSuite.scala

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…es/form/FormRecognizerSuite.scala

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…es/form/FormRecognizerSuite.scala

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…es/vision/ComputerVisionSuite.scala

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…es/vision/ComputerVisionSuite.scala

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BrendanWalsh BrendanWalsh changed the title [chore] Remove deprecated Bing Search APIs and refactor dependent tests chore: Remove deprecated Bing Search APIs and refactor dependent tests Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants