Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
03b3ba7
Add PipelineJob submission and read support to beta.jobs
zzn2 Oct 3, 2026
a3070d4
Narrow PipelineJob assertion type in offline tests
zzn2 Oct 3, 2026
751518e
Accept CommandJob nodes in PipelineJob graphs
zzn2 Oct 3, 2026
deb7a04
Narrow optional Job fields in Pipeline tests
zzn2 Oct 3, 2026
9424d84
Convert Command nodes across PipelineJob model entry points
zzn2 Oct 3, 2026
da5210a
Keep Pipeline command composition constructor scoped
zzn2 Oct 3, 2026
02e4493
Support local code in PipelineJob command nodes
zzn2 Oct 6, 2026
f786ab4
Format two-code PipelineJob tests
zzn2 Oct 6, 2026
1cc8765
Author Foundry pipeline jobs from Python functions
zzn2 Oct 7, 2026
2aa28e2
Format Foundry DSL and pipeline tests
zzn2 Oct 7, 2026
1426c92
Keep generated pipeline code snapshots typed
zzn2 Oct 7, 2026
c88a1ec
Type-check native pipeline submission and sample annotations
zzn2 Oct 7, 2026
82f2d81
Cover typed pipeline ports and component alias offline
zzn2 Oct 7, 2026
9638602
Assert normalized PipelineJob input payloads
zzn2 Oct 7, 2026
36a0c3f
Make unsupported-global component fixture unambiguous
zzn2 Oct 7, 2026
fe3c1d7
Show direct Foundry pipeline decorators in examples
zzn2 Oct 7, 2026
74143d7
[azure-ai-projects] Run Python pipeline components from source snapshots
zzn2 Oct 7, 2026
ad00cb4
[azure-ai-projects] Format component snapshots and fix shared-directo…
zzn2 Oct 7, 2026
491409d
[azure-ai-projects] Keep live source-backed sample out of automatic e…
zzn2 Oct 7, 2026
6238675
[azure-ai-projects] Cover source-backed ignore rules and primitive ports
zzn2 Oct 7, 2026
bb5e277
[azure-ai-projects] Reject Windows junctions in component source snap…
zzn2 Oct 7, 2026
372aa72
[azure-ai-projects] Exercise Windows junction rejection in source sna…
zzn2 Oct 7, 2026
44c6351
[azure-ai-projects] Document junction exclusion for source components
zzn2 Oct 7, 2026
d1deb14
[azure-ai-projects] Serialize pipeline output discriminator for servi…
zzn2 Oct 7, 2026
78b002e
Support uri_folder PipelineJob node bindings
Oct 7, 2026
334e1c3
Merge pull request #9 from zzn2/zhizhu-microsoft-foundry-pipeline-sdk
zzn2 Oct 10, 2026
6e660b9
Merge pull request #4 from zzn2/zhizhu-microsoft-code-pipeline-payload
zzn2 Oct 10, 2026
2bee378
Merge pull request #6 from zzn2/zhizhu-microsoft-foundry-function-com…
zzn2 Oct 10, 2026
314939c
Merge pull request #7 from zzn2/zhizhu-microsoft-foundry-component-so…
zzn2 Oct 10, 2026
1c2129a
Merge PipelineJob feature into uri_folder binding PR
zzn2 Oct 10, 2026
2eb585b
Merge pull request #8 from dhmanigit/users/dhmani/pipeline-uri-folder…
zzn2 Oct 10, 2026
f68b7ca
Fix pipeline SDK documentation build warnings
zzn2 Oct 10, 2026
b8d8fb9
Preinstall SDK runtime dependencies for APIView generation
zzn2 Oct 10, 2026
b30c3eb
Fix PipelineJob SDK analysis and dependency checks
zzn2 Oct 10, 2026
c352950
Exclude live PipelineJob samples from standalone checks
zzn2 Oct 10, 2026
4758182
feat(ai-projects): allow uri_folder in pipeline decorators
zzn2 Oct 13, 2026
f036f6d
test(ai-projects): assert serialized pipeline output type
zzn2 Oct 13, 2026
bd46e73
Merge pull request #10 from zzn2/zhizhu-microsoft-silver-winner
zzn2 Oct 13, 2026
4f22c44
feat(ai-projects): expose dedicated pipeline jobs client
Oct 22, 2026
ea1635f
Merge pull request #11 from dhmanigit/users/dhmani/foundry-pipeline-j…
zzn2 Nov 2, 2026
1b705fc
Support nested pipeline authoring and recursive component source upload
zzn2 Nov 3, 2026
2db6254
Preserve explicit compute selection in nested pipelines
zzn2 Nov 3, 2026
5619eee
Route Pipeline Jobs facade through existing Jobs ingress
zzn2 Nov 3, 2026
c693a82
Register authored Pipeline Command components before job submission
zzn2 Nov 5, 2026
08db0ec
Update offline Pipeline fixtures for registered component submissions
zzn2 Nov 5, 2026
7c0c029
Verify registration with standard azure-core REST responses
zzn2 Nov 5, 2026
3dfe427
Provide a complete in-memory Requests response fixture
zzn2 Nov 5, 2026
020bb6a
Fix Pipeline and single-file job output downloads
zzn2 Nov 11, 2026
db87382
Refine offline output download fixtures
zzn2 Nov 11, 2026
835c35d
Fix PipelineJob typing and memory paging request
zzn2 Nov 13, 2026
0e1db7c
Cover memory list scope serialization
zzn2 Nov 13, 2026
87fa4e0
Document PipelineJob response conversion for pylint
zzn2 Nov 13, 2026
8bd2791
Complete PipelineJob converter parameter docs
zzn2 Nov 13, 2026
5c1ee09
Format memory scope regression tests
zzn2 Nov 13, 2026
f051a56
Merge feature/azure-ai-projects/training-prpr-2.2.0-pipelines into zh…
zzn2 Dec 4, 2026
0a9f84b
Merge feature/azure-ai-projects/training-prpr-2.2.0-pipelines into zh…
zzn2 Dec 4, 2026
2f46fe2
Merge feature/azure-ai-projects/training-prpr-2.2.0-pipelines into zz…
zzn2 Dec 4, 2026
aa1a078
Merge feature/azure-ai-projects/training-prpr-2.2.0-pipelines into zh…
zzn2 Dec 4, 2026
a3ec1a2
Merge nested pipeline support into register-command branch
zzn2 Dec 4, 2026
cddb8f9
Merge pipeline_jobs /jobs routing into register-command branch
zzn2 Dec 4, 2026
347ad71
Assert pipeline_jobs requests use the /jobs route
zzn2 Dec 4, 2026
1e99839
Merge pipeline_jobs /jobs route test updates into register-command br…
zzn2 Dec 4, 2026
fd21280
Merge nested pipeline support into pipeline_jobs /jobs routing branch
zzn2 Dec 4, 2026
d1fce88
Expect nested pipeline submissions on the /jobs route
zzn2 Dec 4, 2026
c169cd8
Merge pipeline_jobs /jobs routing updates into register-command branch
zzn2 Dec 4, 2026
62afc16
Align registration tests with /jobs routing and nested pipelines
zzn2 Dec 4, 2026
4c78578
Apply black formatting to nested pipeline changes
zzn2 Dec 4, 2026
7573601
Merge commit '4c785781726fbe333f88d19897c9bc0bb2e73291' into pr/zhizh…
zzn2 Dec 4, 2026
b005064
Merge commit '7573601e9cffd33bbe1319f38009f4e94724bd06' into pr/zhizh…
zzn2 Dec 4, 2026
d4738ce
Scope pylint suppressions for pipeline DSL builder
zzn2 Dec 4, 2026
70f461d
Merge commit 'd4738ceebecf30cc4d4271ed06c31ee58a7417e2' into pr/zhizh…
zzn2 Dec 4, 2026
117cf0e
Merge commit '70f461d30d8e98fd5d7a8bda6a8a361425677f2c' into pr/zhizh…
zzn2 Dec 4, 2026
67ce2b7
Suppress sibling-module import false positive in async registration o…
zzn2 Dec 4, 2026
ed67658
Merge commit '2f46fe2ff3042206bcb8f3dab81cd86cdfaea171' into pr/zhizh…
zzn2 Dec 4, 2026
c556aab
Merge pull request #12 from zzn2/zhizhu-microsoft-nested-pipeline-sdk
zzn2 Dec 4, 2026
6e39792
Merge pull request #13 from zzn2/zhizhu-microsoft-pipeline-jobs-via-jobs
zzn2 Dec 4, 2026
1dd1f88
Merge pull request #15 from zzn2/zzn2-pipeline-output-download-fix
zzn2 Dec 4, 2026
4c2f41e
Merge commit '1dd1f88c1bc21231623fbf853ee55851e9bc6e4a' into pr/zhizh…
zzn2 Dec 4, 2026
9cb7ec2
Merge pull request #14 from zzn2/zhizhu-microsoft-register-command-be…
zzn2 Dec 4, 2026
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
7 changes: 7 additions & 0 deletions eng/tools/azure-sdk-tools/azpysdk/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@

# Add your library + sample file if you do not want a particular sample to be run
IGNORED_SAMPLES = {
"azure-ai-projects": [
"sample_pipeline_dsl.py",
"sample_pipeline_hello_world.py",
"sample_pipeline_source.py", # Submits a live PipelineJob.
"sample_pipeline_two_code.py",
"source_pipeline_components.py", # Imports helpers relative to its package.
],
"azure-appconfiguration-provider": [
"key_vault_reference_customized_clients_sample.py",
"aad_sample.py",
Expand Down
10 changes: 10 additions & 0 deletions sdk/ai/azure-ai-projects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
* New optional `force` parameter on `agents.delete` and `agents.delete_version` methods.
* New optional `blueprint_reference` parameters on `agents.create_version` method.
* New `.beta.jobs` sub-client with CommandJob operations: `create_or_update`, `get`, `list`, `begin_delete`, `begin_cancel`, `validate`, `show_services`, `stream`, `download`.
* Added dedicated `.pipeline_jobs.create_or_update`, `.get`, and `.list` operations (sync and async) on the `/pipeline_jobs` ingress. Local code folders on inline command nodes are registered as Code datasets before submission. The earlier `.beta.jobs` Pipeline support remains for preview compatibility.
* When constructing `PipelineJob`, `jobs` accepts `CommandJob` instances with value-bound literal, `uri_file`, and `uri_folder` inputs, code, and outputs and converts them to inline command nodes. Raw graph dictionaries remain supported for other node features.
* Added `azure.ai.projects.dsl` function-body `@component` and `@pipeline` authoring for native two-step PipelineJobs. Calling the pipeline function builds its graph, packages each Python component body as its own executable Code folder, binds typed inputs and file outputs, and supports repeated component calls. `.pipeline_jobs.create_or_update(pipeline_job)` generates a unique name (sync and async), while the explicit-name form remains available.
* Added opt-in `@component(code=...)` source-backed components for local helper functions, sibling modules, and resources. Code roots are snapshot with ignore rules before upload and shared by nodes in the same pipeline. Executing these components requires the image to contain a compatible `azure-ai-projects` package and other imported dependencies; bare `@component` keeps its existing standalone execution behavior.
* Added nested `@pipeline` composition with parent-owned input/output bindings, preserved Pipeline component hierarchy, and explicit nested compute selection. Nested command source folders are resolved on both job submission surfaces, shared code roots are uploaded once across the graph, and the root job owns staged-folder cleanup. Submission requires service support for inline Pipeline component registration.
* New optional `priority` property on class `CommandJob`, typed as the new `JobPriority` enum (`LOW`, `MID`, `HIGH`). If omitted, the service defaults to `LOW`.
* New optional `experiment_name` property on class `CommandJob`, used to group related runs. If omitted, the service uses `Default`.
* `.beta.jobs.create_or_update` now emits a `UserWarning` when a newly created job sets `resources.instance_type`, `resources.shm_size`, `resources.docker_args` or `resources.properties`. The service infers these from the target compute and ignores them, so they were previously dropped silently. The call still succeeds, and jobs retrieved with `.beta.jobs.get` are not affected.
Expand Down Expand Up @@ -65,6 +70,8 @@ Breaking changes in beta classes:

### Bugs Fixed

* Fixed synchronous and asynchronous `.beta.jobs.download` to handle Pipeline output mappings and download exact `uri_file` blobs without including similarly prefixed sibling blobs.
* Pipeline submissions register top-level inline Command components after uploading their Code and submit the returned opaque component IDs. Registration failures prevent job submission, and the original authored components remain reusable.
* Fixed telemetry instrumentor to correctly call is_recording() as a method on spans, ensuring non-recording spans are properly skipped (e.g., when sampling is configured) ([GitHub issue 46544](https://github.com/Azure/azure-sdk-for-python/issues/46544)).
* Fixed `load_job` dropping the `outputs` block of a job YAML file. Unlike `inputs`, outputs were not converted into `Output` instances, so a YAML file using the documented snake_case field names (for example `asset_name`) was serialized with those names verbatim instead of their wire names, and the values never reached the service. Outputs are now converted in the same way as inputs.
* Fixed `ModuleNotFoundError: No module named 'httpx'` when installing the package into a clean environment. `httpx` is imported directly by the client but was only ever satisfied transitively through `openai`; `openai` 3.0.0 replaced that dependency with `httpx2`, so `httpx` stopped being installed. `httpx` is now declared explicitly, and `openai` is capped below 3.0.0 because the client still passes an `httpx.Client` to `OpenAI(http_client=...)`.
Expand All @@ -86,6 +93,9 @@ Breaking changes in beta classes:
* Refreshed evaluation samples under `samples/evaluations/` and `samples/evaluations/agentic_evaluators/` (including `sample_agent_evaluation`, `sample_agent_response_evaluation`, `sample_eval_catalog_prompt_based_evaluators`, `sample_evaluations_ai_assisted`, `sample_evaluations_builtin_with_csv`, `sample_evaluations_builtin_with_dataset_id`, `sample_evaluations_builtin_with_inline_data`, `sample_evaluations_builtin_with_inline_data_oai`, `sample_scheduled_evaluations`, `sample_coherence`, `sample_fluency`, `sample_intent_resolution`, `sample_relevance`, `sample_response_completeness`, `sample_tool_call_accuracy`, `sample_tool_call_success`, `sample_tool_input_accuracy`, `sample_tool_output_utilization`, `sample_tool_selection`, and `sample_generic_agentic_evaluator`).
* New sample `sample_dataset_generation_job_simpleqna_with_prompt_source.py` showing an end-to-end flow that generates a QnA dataset via `.beta.datasets.create_generation_job` and runs an OpenAI evaluation.
* Updated job samples `sample_jobs.py` and `sample_jobs_async.py` to show requesting GPUs with `gpu_count` on a GPU cluster versus whole nodes with `instance_count` on a CPU cluster, and to set the new `priority` property.
* Added `sample_pipeline_two_code.py` to demonstrate a producer and consumer using separate local code folders and a mounted file output.
* Added `sample_pipeline_dsl.py` to show Python function components and direct pipeline-function job construction.
* Added `sample_pipeline_nested.py` to show a two-command subgraph called from a parent pipeline and connected to an outer command through its exported output.

## 2.1.0 (2026-04-20)

Expand Down
55 changes: 54 additions & 1 deletion sdk/ai/azure-ai-projects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ resources in your Microsoft Foundry Project. Use it to:
* **Upload documents and create Datasets** to reference them using `.datasets` operations.
* **Register and manage local model weights** as Foundry `ModelVersion` resources using `.beta.models` operations, including the `create` end-to-end helper.
* **Create and enumerate Search Indexes** using `.indexes` operations.
* **Submit and manage Jobs (preview)** to run Training Jobs on compute using `.beta.jobs` operations.
* **Submit and manage Command Jobs (preview)** on compute using `.beta.jobs` operations.
* **Submit and inspect Pipeline Jobs (preview)** using the dedicated `.pipeline_jobs` operations.

The client library uses version `v1` of the Microsoft Foundry [data plane REST APIs](https://aka.ms/azsdk/azure-ai-projects-v2/api-reference-v1).

Expand Down Expand Up @@ -173,6 +174,58 @@ Full descriptions and working code for all of the above are available in:
| Files (upload, retrieve, list, delete) | [OpenAI Files API](https://platform.openai.com/docs/api-reference/files) | `samples/files/` |
| Fine-tuning | [Fine-Tuning in AI Foundry](https://github.com/microsoft-foundry/fine-tuning) | `samples/finetuning/` |

### Author Python function pipeline jobs (preview)

Use `from azure.ai.projects.dsl import Input, Output, component, pipeline` to define a Python
function body with `@component` and call that component inside a `@pipeline` function.
`Input(type="uri_file")` and `Output(type="uri_file")` declare file ports; output names are inferred
from parameter names and file outputs use read-write mounts by default. The pipeline decorator
supplies the compute resource ID, container image, user-assigned identity ID, and instance type
inherited by its nodes.
Calling the decorated pipeline function constructs a native Foundry `PipelineJob` without an outer
builder. Submit it with `client.pipeline_jobs.create_or_update(job)` for an autogenerated job name,
optionally passing `experiment_name="pipeline_samples"`, or use the existing
`create_or_update(name=..., job=...)` form.

Call one decorated `@pipeline` function from another to add a nested Pipeline node,
then connect its exported outputs through `stage.outputs.<name>` just like command
outputs. The nested graph is preserved, not flattened; its commands bind to their own
pipeline inputs and exported outputs. See the [nested pipeline sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/jobs/sample_pipeline_nested.py).
If the nested decorator selects a different compute resource ID, its Pipeline invocation retains that selection instead of inheriting the parent default.

Submission uploads local Code first, then registers each top-level inline Command component
using its existing name and version. The submitted graph contains the service's opaque
`componentId`; the authored component remains reusable. Registration errors prevent job
submission, with no inline fallback or default GET. Existing registered references are
preserved. This requires the project's Component PUT route for `2026-01-15-preview`
to be deployed and authorized; Commands inside nested Pipeline
components are submitted inline, and nested Pipeline component registration is not supported.

See the [two-component Python sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/jobs/sample_pipeline_dsl.py) for a producer and
consumer connected through a mounted file. Each function body is packaged into a separate Code
folder and runs on the selected compute, not when the graph is built. Component functions must be
defined in a readable `.py` file; referenced module-level imports are copied into the generated
entrypoint, but non-import globals, closures, and sibling source files are not bundled. Required
third-party modules must already exist in the container image. This native Foundry authoring API
does not accept an unmodified `azure.ai.ml.dsl` PipelineJob or provide full Azure ML component
registration and environment features; local pipeline file inputs are not supported.

For helpers and local modules, use `@component(code="..")` to opt into a source-backed Code
snapshot. The path is relative to the file defining the component; it must include that file
and the top-level Python package to import. The runtime imports the original module and invokes
its undecorated function, so module globals, sibling Python files, and resources inside that
root are available. Define components in import-safe modules separate from submission-time
configuration. The selected image must contain a compatible `azure-ai-projects` version and
any other imported Python packages; the snapshot does not install dependencies or capture
closure values. Shared code roots are uploaded once per pipeline submission, including
across nested pipelines. The root job owns all staged Code folders and cleans them up
after code resolution, including when a nested upload fails.
The snapshot honors `.amlignore` (or `.gitignore` when no `.amlignore` exists) in each directory,
always omits `.env` files and common Python/Git artifacts, and rejects included symlinks.
Review the code root before submitting: only files not excluded by these rules are uploaded.
See the [multi-file source-backed sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ai/azure-ai-projects/samples/jobs/pipeline_source/README.md) for this
layout; the original single-file sample retains its standalone, SDK-free execution mode.

### Hosted agents (preview)

Hosted agents let you run your own containerized agent runtime while using Microsoft Foundry for managed hosting and scaling.
Expand Down
12 changes: 10 additions & 2 deletions sdk/ai/azure-ai-projects/apiview-properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@
"azure.ai.projects.models.Output": "Azure.AI.Projects.Output",
"azure.ai.projects.models.PendingUploadRequest": "Azure.AI.Projects.PendingUploadRequest",
"azure.ai.projects.models.PendingUploadResponse": "Azure.AI.Projects.PendingUploadResponse",
"azure.ai.projects.models.PipelineJob": "Azure.AI.Projects.PipelineJob",
"azure.ai.projects.models.PipelineJobResource": "Azure.AI.Projects.PipelineJobResource",
"azure.ai.projects.models.ProceduralMemoryItem": "Azure.AI.Projects.ProceduralMemoryItem",
"azure.ai.projects.models.PromoteCandidateRequest": "Azure.AI.Projects.PromoteCandidateRequest",
"azure.ai.projects.models.PromoteCandidateResponse": "Azure.AI.Projects.PromoteCandidateResponse",
Expand Down Expand Up @@ -501,7 +503,13 @@
"azure.ai.projects.operations.IndexesOperations.delete": "Azure.AI.Projects.Indexes.deleteVersion",
"azure.ai.projects.aio.operations.IndexesOperations.delete": "Azure.AI.Projects.Indexes.deleteVersion",
"azure.ai.projects.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion",
"azure.ai.projects.aio.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion"
"azure.ai.projects.aio.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion",
"azure.ai.projects.operations.PipelineJobsOperations.list": "Azure.AI.Projects.PipelineJobs.list",
"azure.ai.projects.aio.operations.PipelineJobsOperations.list": "Azure.AI.Projects.PipelineJobs.list",
"azure.ai.projects.operations.PipelineJobsOperations.get": "Azure.AI.Projects.PipelineJobs.get",
"azure.ai.projects.aio.operations.PipelineJobsOperations.get": "Azure.AI.Projects.PipelineJobs.get",
"azure.ai.projects.operations.PipelineJobsOperations.create_or_update": "Azure.AI.Projects.PipelineJobs.createOrUpdate",
"azure.ai.projects.aio.operations.PipelineJobsOperations.create_or_update": "Azure.AI.Projects.PipelineJobs.createOrUpdate"
},
"CrossLanguageVersion": "454439a0b62a"
"CrossLanguageVersion": "fa3ed1607aa3"
}
4 changes: 4 additions & 0 deletions sdk/ai/azure-ai-projects/azure/ai/projects/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
DeploymentsOperations,
EvaluationRulesOperations,
IndexesOperations,
PipelineJobsOperations,
)

if sys.version_info >= (3, 11):
Expand Down Expand Up @@ -52,6 +53,8 @@ class AIProjectClient: # pylint: disable=too-many-instance-attributes
:vartype deployments: azure.ai.projects.operations.DeploymentsOperations
:ivar indexes: IndexesOperations operations
:vartype indexes: azure.ai.projects.operations.IndexesOperations
:ivar pipeline_jobs: PipelineJobsOperations operations
:vartype pipeline_jobs: azure.ai.projects.operations.PipelineJobsOperations
:param endpoint: Foundry Project endpoint in the form
"https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you
only have one Project in your Foundry Hub, or to target the default Project in your Hub, use
Expand Down Expand Up @@ -108,6 +111,7 @@ def __init__(
self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize)
self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize)
self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize)
self.pipeline_jobs = PipelineJobsOperations(self._client, self._config, self._serialize, self._deserialize)

def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
Expand Down
39 changes: 39 additions & 0 deletions sdk/ai/azure-ai-projects/azure/ai/projects/_component_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
"""Execute a source-backed component from a mounted Code snapshot."""

import importlib
import sys
from typing import Callable, Dict


def _boolean(value: str) -> bool:
return value == "True"


_CONVERSIONS: Dict[str, Callable[[str], object]] = {
"str": str,
"int": int,
"float": float,
"bool": _boolean,
}


def main() -> None:
module_name, function_name, port_spec = sys.argv[1:4]
ports = [] if port_spec == "-" else [port.split(":", 1) for port in port_spec.split(",")]
values = sys.argv[4:]
if len(ports) != len(values):
raise ValueError(f"Component '{function_name}' expected {len(ports)} arguments, got {len(values)}.")

wrapped = getattr(importlib.import_module(module_name), function_name)
function = getattr(wrapped, "__wrapped__", None)
if function is None:
raise TypeError(f"Component '{module_name}.{function_name}' is not decorated with @component.")
function(**{name: _CONVERSIONS[conversion](value) for (name, conversion), value in zip(ports, values)})


if __name__ == "__main__":
main()
Loading
Loading