Skip to content

Commit 254afae

Browse files
authored
Release v2.6.1 (#550)
2 parents 296513d + 64a3f82 commit 254afae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+991
-969
lines changed

.github/workflows/pythonci.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: Python CI
22

33
on:
4-
push:
5-
branches: [ main, dev ]
6-
pull_request:
7-
branches: [ main, dev ]
4+
push
85

96
jobs:
107
backend:
@@ -14,13 +11,13 @@ jobs:
1411
strategy:
1512
fail-fast: false
1613
matrix:
17-
python-version: [ "3.8" ]
14+
python-version: [ "3.9" ]
1815

1916
steps:
2017
- uses: actions/checkout@v3
2118
- uses: actions/setup-python@v1
2219
with:
23-
python-version: 3.8
20+
python-version: 3.9
2421
- uses: Gr1N/setup-poetry@v7
2522
- uses: actions/cache@v2
2623
with:

.github/workflows/webapp_ci.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: Webapp CI
22

33
on:
4-
push:
5-
branches: [ main, dev ]
6-
pull_request:
7-
branches: [ main, dev ]
4+
push
85

96
jobs:
107
frontend:

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM pytorch/pytorch:1.8.1-cuda11.1-cudnn8-runtime as build_gpu
44
# Copy binaries from other images here
55
RUN pip install --upgrade pip
66

7-
FROM python:3.8 as build_cpu
7+
FROM python:3.9 as build_cpu
88
# NOOP step on CPU
99
FROM build_${DEVICE}
1010

azimuth/app.py

+31-10
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@
2525

2626
from azimuth.config import AzimuthConfig, load_azimuth_config
2727
from azimuth.dataset_split_manager import DatasetSplitManager
28-
from azimuth.modules.base_classes import DaskModule
29-
from azimuth.modules.utilities.validation import ValidationModule
28+
from azimuth.modules.base_classes import ArtifactManager, DaskModule
3029
from azimuth.startup import startup_tasks
3130
from azimuth.task_manager import TaskManager
32-
from azimuth.types import DatasetSplitName, ModuleOptions
31+
from azimuth.types import DatasetSplitName, ModuleOptions, SupportedModule
3332
from azimuth.utils.cluster import default_cluster
3433
from azimuth.utils.conversion import JSONResponseIgnoreNan
3534
from azimuth.utils.logs import set_logger_config
36-
from azimuth.utils.project import load_dataset_split_managers_from_config
3735
from azimuth.utils.validation import assert_not_none
3836

3937
_dataset_split_managers: Dict[DatasetSplitName, Optional[DatasetSplitManager]] = {}
@@ -297,6 +295,32 @@ def create_app() -> FastAPI:
297295
return app
298296

299297

298+
def load_dataset_split_managers_from_config(
299+
azimuth_config: AzimuthConfig,
300+
) -> Dict[DatasetSplitName, Optional[DatasetSplitManager]]:
301+
"""
302+
Load all dataset splits for the application.
303+
304+
Args:
305+
azimuth_config: Azimuth Configuration.
306+
307+
Returns:
308+
For all DatasetSplitName, None or a dataset_split manager.
309+
310+
"""
311+
artifact_manager = ArtifactManager.instance()
312+
dataset = artifact_manager.get_dataset_dict(azimuth_config)
313+
314+
return {
315+
dataset_split_name: None
316+
if dataset_split_name not in dataset
317+
else artifact_manager.get_dataset_split_manager(
318+
azimuth_config, DatasetSplitName[dataset_split_name]
319+
)
320+
for dataset_split_name in [DatasetSplitName.eval, DatasetSplitName.train]
321+
}
322+
323+
300324
def initialize_managers(azimuth_config: AzimuthConfig, cluster: SpecCluster):
301325
"""Initialize DatasetSplitManagers and TaskManagers.
302326
@@ -334,22 +358,19 @@ def run_validation(
334358
"""
335359

336360
def run_validation_module(pipeline_index=None):
337-
validation_module = ValidationModule(
338-
config=config,
361+
_, task = task_manager.get_task(
362+
task_name=SupportedModule.Validation,
339363
dataset_split_name=dataset_split,
340364
mod_options=ModuleOptions(pipeline_index=pipeline_index),
341365
)
342-
validation_module.start_task_on_dataset_split(task_manager.client)
343366
# Will raise exceptions as needed.
344-
validation_module.result()
367+
task.result()
345368

346369
if config.pipelines is None:
347370
run_validation_module()
348371
else:
349372
for pipeline_index in range(len(config.pipelines)):
350373
run_validation_module(pipeline_index)
351-
task_manager.clear_worker_cache()
352-
task_manager.restart()
353374

354375

355376
def run_startup_tasks(azimuth_config: AzimuthConfig, cluster: SpecCluster):

azimuth/config.py

+23-10
Original file line numberDiff line numberDiff line change
@@ -200,24 +200,27 @@ class SyntaxOptions(AzimuthBaseSettings):
200200

201201

202202
class NeutralTokenOptions(AzimuthBaseSettings):
203-
threshold: float = 1
203+
threshold: float = Field(1, ge=0, le=1)
204204
suffix_list: List[str] = [] # Language-based default value
205205
prefix_list: List[str] = [] # Language-based default value
206206

207207

208208
class PunctuationTestOptions(AzimuthBaseSettings):
209-
threshold: float = 1
209+
threshold: float = Field(1, ge=0, le=1)
210210

211211

212212
class FuzzyMatchingTestOptions(AzimuthBaseSettings):
213-
threshold: float = 1
213+
threshold: float = Field(1, ge=0, le=1)
214214

215215

216216
class TypoTestOptions(AzimuthBaseSettings):
217-
threshold: float = 1
218-
# Ex: if nb_typos_per_utterance = 2, this will create both tests with 1 typo and 2 typos per
219-
# utterance.
220-
nb_typos_per_utterance: int = 1
217+
threshold: float = Field(1, ge=0, le=1)
218+
nb_typos_per_utterance: int = Field(
219+
1,
220+
ge=1,
221+
description="For example, the value 2 would create both tests with 1 typo and with 2 typos "
222+
"per utterance.",
223+
)
221224

222225

223226
class BehavioralTestingOptions(AzimuthBaseSettings):
@@ -355,6 +358,16 @@ def check_pipeline_names(cls, pipeline_definitions):
355358
raise ValueError(f"Duplicated pipeline names {pipeline_names}.")
356359
return pipeline_definitions
357360

361+
def get_model_contract_hash(self):
362+
"""Hash for fields related to model contract only (excluding fields from the parents)."""
363+
return md5_hash(
364+
self.dict(
365+
include=ModelContractConfig.__fields__.keys()
366+
- CommonFieldsConfig.__fields__.keys(),
367+
by_alias=True,
368+
)
369+
)
370+
358371

359372
class MetricsConfig(ModelContractConfig):
360373
# Custom HuggingFace metrics
@@ -445,10 +458,9 @@ def dynamic_language_config_values(cls, values):
445458

446459
@classmethod
447460
def load(cls, config_path: Optional[str], load_config_history: bool) -> "AzimuthConfig":
448-
# Loading config from config_path if specified, or else from environment variables only.
449-
cfg = ArtifactsConfig.parse_file(config_path) if config_path else ArtifactsConfig()
450-
451461
if load_config_history:
462+
# Load artifact_path from config_path if specified, or else from env var ARTIFACT_PATH.
463+
cfg = ArtifactsConfig.parse_file(config_path) if config_path else ArtifactsConfig()
452464
config_history_path = cfg.get_config_history_path()
453465
last_config = cls.load_last_from_config_history(config_history_path)
454466
if last_config:
@@ -457,6 +469,7 @@ def load(cls, config_path: Optional[str], load_config_history: bool) -> "Azimuth
457469

458470
log.info("Empty or invalid config history.")
459471

472+
# Load config from config_path if specified, or else from env vars only.
460473
return cls.parse_file(config_path) if config_path else cls()
461474

462475
@classmethod

0 commit comments

Comments
 (0)