-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from AlejandroBaron/develop
release v0.1.1
- Loading branch information
Showing
9 changed files
with
163 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build and Deploy | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
permissions: | ||
contents: write | ||
jobs: | ||
Testing: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
python-version: [3.9, '3.10', '3.11'] | ||
os: [ubuntu-latest, macOS-latest, windows-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up PDM | ||
uses: pdm-project/setup-pdm@v4.1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
pdm sync -d -G testing | ||
- name: Run Tests | ||
run: | | ||
pdm run -v pytest tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ dependencies: | |
- mldesigner==0.1.0b17 | ||
- azure-ai-ml==1.18.0 | ||
- azureml-mlflow==1.56.0 | ||
- ez-azml==0.1.0 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .pipeline import Pipeline | ||
from .pipeline import Pipeline, PipelineCommand | ||
|
||
__all__ = ["Pipeline"] | ||
__all__ = ["Pipeline", "PipelineCommand"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import inspect | ||
from typing import Callable | ||
from unittest import mock | ||
|
||
from ez_azml.cloud_runs.pipelines import Pipeline | ||
|
||
|
||
def assert_function_wrapped(function: Callable, wrapped_function: Callable) -> None: | ||
"""Asserts that a function is properly wrapped. | ||
Args: | ||
wrapped_function: The function that is potentially wrapped. | ||
function: The original function to compare against after unwrapping. | ||
Raises: | ||
AssertionError: If the function is already wrapped or if unwrapping the wrapped | ||
function does not yield the original function. | ||
""" | ||
assert not hasattr(function, "__wrapped__"), "The function should not be wrapped." | ||
assert ( | ||
inspect.unwrap(wrapped_function) is function | ||
), "Unwrapping the wrapped function did not yield the original function." | ||
|
||
|
||
def test_pipeline_register_components(pipeline: Pipeline): | ||
"""Tests that the components are properly decorated.""" | ||
raw_functions = [c.function for c in pipeline.commands] | ||
registered_commands = pipeline._register_components(pipeline.commands) | ||
for raw_function, registered in zip(raw_functions, registered_commands): | ||
assert_function_wrapped(raw_function, registered.function) | ||
|
||
|
||
def test_pipeline_setup_dec_kwargs(pipeline: Pipeline): | ||
"""Tests that the pipeline decorator kwargs are properly postprocessed.""" | ||
pipeline.dec_kwargs = pipeline._setup_dec_kwargs(pipeline.dec_kwargs) | ||
|
||
|
||
def test_build_pipeline(pipeline: Pipeline): | ||
"""Tests that the pipeline is properly decorated.""" | ||
|
||
def f(): | ||
pass | ||
|
||
with mock.patch.object(pipeline, "commands", return_value=f) as mocked: | ||
mocked.__name__ = "command_fn" | ||
|
||
raw_pipeline = pipeline.pipeline | ||
built_pipeline = pipeline._build_pipeline(raw_pipeline, pipeline.dec_kwargs) | ||
assert_function_wrapped(raw_pipeline, built_pipeline) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from typing import Callable | ||
|
||
import mldesigner as mld | ||
import pytest | ||
from azure.ai.ml import Input, Output | ||
from ez_azml.cloud_runs.pipelines import Pipeline, PipelineCommand | ||
|
||
|
||
@pytest.fixture() | ||
def command_fn() -> Callable: | ||
"""Function used in mldesigner command component.""" | ||
|
||
def command__fn( | ||
command_input: mld.Input(type="uri_folder"), # type: ignore | ||
command_output: mld.Output(type="uri_folder"), # type: ignore | ||
): | ||
print("this is a test_fn") | ||
|
||
return command__fn | ||
|
||
|
||
@pytest.fixture() | ||
def pipeline_fn(command_fn) -> Callable: | ||
"""Function used in azure.ai.ml pipelines.""" | ||
|
||
def pipeline__fn( | ||
pipeline_input: Input, | ||
pipeline_output: Output, | ||
): | ||
command_fn(pipeline_input) | ||
|
||
return pipeline__fn | ||
|
||
|
||
@pytest.fixture() | ||
def pipeline_command(command_fn: Callable): | ||
"""PipelineCommand fixture.""" | ||
return PipelineCommand(function=command_fn) | ||
|
||
|
||
@pytest.fixture() | ||
def pipeline(pipeline_fn: Callable, pipeline_command: PipelineCommand): | ||
"""Pipeline cloud run fixture.""" | ||
return Pipeline( | ||
experiment_name="fixture", | ||
commands=[pipeline_command], | ||
pipeline=pipeline_fn, | ||
) |