Skip to content
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
6 changes: 3 additions & 3 deletions .pipelines/v2/templates/stages-cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ stages:
steps:
- checkout: self
clean: true
- template: steps-build-cs.yml
- template: steps-build-cs.yml@self
parameters:
flNugetDir: '$(Pipeline.Workspace)/cpp-nuget'
outputDir: '$(Build.ArtifactStagingDirectory)/cs-sdk'
Expand Down Expand Up @@ -132,7 +132,7 @@ stages:
- checkout: self
clean: true
- template: ../../templates/fetch-test-data-from-blob.yml@self
- template: steps-test-cs.yml
- template: steps-test-cs.yml@self
parameters:
flNugetDir: '$(Pipeline.Workspace)/cpp-nuget'
testDataSharedDir: '$(Build.SourcesDirectory)/test-data-shared'
Expand Down Expand Up @@ -193,7 +193,7 @@ stages:
- checkout: self
clean: true
- template: ../../templates/fetch-test-data-from-blob.yml@self
- template: steps-test-cs.yml
- template: steps-test-cs.yml@self
parameters:
flNugetDir: '$(Pipeline.Workspace)/cpp-nuget'
testDataSharedDir: '$(Build.SourcesDirectory)/test-data-shared'
Expand Down
1 change: 0 additions & 1 deletion sdk_v2/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ set(FOUNDRY_LOCAL_SOURCES
src/util/file_lock.cc
src/http/http_download.cc
src/util/path_safety.cc
src/util/region_fallback.cc
src/util/sha256.cc
src/util/zip_extract.cc
${FOUNDRY_LOCAL_PLATFORM_SOURCES}
Expand Down
244 changes: 116 additions & 128 deletions sdk_v2/cpp/src/catalog/azure_catalog_client.cc

Large diffs are not rendered by default.

32 changes: 11 additions & 21 deletions sdk_v2/cpp/src/catalog/azure_catalog_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "http/http_client.h"
#include "logger.h"
#include "model_info.h"
#include "util/region_fallback.h"

#include <functional>
#include <optional>
Expand All @@ -18,31 +17,30 @@
namespace fl {

/// Live Azure Foundry catalog client. Queries the catalog REST API
/// (`{base_url}/entities/crossRegion`) for the models available to the local
/// (`asset-gallery/v1.0/models`) for the models available to the local
/// hardware, paginating through results and converting each entry to ModelInfo.
///
/// Uses one filter set per detected device, page size 50, and pagination via
/// skip + continuationToken.
/// skip + continuationToken. The detected region is stamped onto results so
/// downloads can target the matching regional model registry.
class AzureCatalogClient : public ICatalogClient {
public:
/// Response-aware HTTP POST. Used for region detection, catalog fetches, and regional fallback.
/// Response-aware HTTP POST. Used for region detection and catalog fetches.
using HttpPostResponseFn =
std::function<http::HttpResponse(const std::string& url, const std::string& body)>;

/// @param base_url Catalog base URL, e.g. "https://ai.azure.com/api/centralus/ux/v1.0".
/// @param filter_override Foundry Local tag filter. "" means public models; "''" means a single empty value.
/// @param base_url Catalog endpoint. Empty means the default V2 asset-gallery endpoint.
/// @param filter_override Deployment-option override. Empty means `foundryLocalDevices`.
/// @param ep_detector Reports available device and execution-provider pairs.
/// @param logger Logger.
/// @param http_post HTTP POST implementation. The default uses `http::HttpPostWithResponse`.
/// @param catalog_region Catalog region. Empty or "auto" detects from Azure headers; any other value is explicit.
/// @param region_fallback_enabled Enables retries through nearby regions when a regional endpoint is unhealthy.
AzureCatalogClient(const std::string& base_url,
const std::string& filter_override,
const IEpDetector& ep_detector,
ILogger& logger,
HttpPostResponseFn http_post = {},
std::string catalog_region = "",
bool region_fallback_enabled = true);
std::string catalog_region = "");

/// Fetch every catalog model entry visible to the local hardware (raw form,
/// before conversion to ModelInfo). One filter set per device, fully paginated.
Expand All @@ -67,28 +65,20 @@ class AzureCatalogClient : public ICatalogClient {
std::string region;
};

/// Run all pages of one filter set. In regional mode the first page goes through region fallback and later pages are
/// pinned to the serving region; a retryable region-health failure fails just this filter set (others continue).
/// Run all pages of one filter set.
std::optional<FetchedFilterSet> FetchFilterSet(const std::vector<CatalogFilter>& filters);

/// Fetch every device filter set, dropping the ones that failed their region-health checks.
/// Used for unbounded "latest only" / by-id queries.
/// Fetch every device filter set.
std::vector<FetchedFilterSet> FetchAllFilterSets();

std::string base_url_;
std::vector<std::string> model_filter_; // foundryLocal tag values
std::vector<std::string> model_filter_; // deploymentOptions filter values
const IEpDetector& ep_detector_;
ILogger& logger_;
HttpPostResponseFn http_post_response_;
RegionFallback region_fallback_;

// Region state. region_ is the active region (empty = use base_url verbatim).
// When base_url matches the https://{host}/api/{region}/{suffix} template,
// url_prefix_/url_suffix_ let us synthesize per-region URLs.
// Region state used for model-registry routing after catalog discovery.
std::string region_;
std::string url_prefix_;
std::string url_suffix_;
bool regional_template_ = false;
};

} // namespace fl
Loading
Loading