项目文件夹

文件
wehub-resource-sync 593b94c120
pytest / Unit Tests (push) Has been cancelled
pytest / Integration (integration_tests_a) (push) Has been cancelled
pytest / Integration (integration_tests_b) (push) Has been cancelled
pytest / Integration (integration_tests_c) (push) Has been cancelled
pytest / Integration (integration_tests_d) (push) Has been cancelled
pytest / Integration (integration_tests_e) (push) Has been cancelled
pytest / Integration (integration_tests_f) (push) Has been cancelled
pytest / Integration (integration_tests_g) (push) Has been cancelled
pytest / Integration (integration_tests_h) (push) Has been cancelled
pytest / Integration (integration_tests_i) (push) Has been cancelled
pytest / Integration (integration_tests_j) (push) Has been cancelled
pytest / Distributed (distributed_a) (push) Has been cancelled
pytest / Distributed (distributed_b) (push) Has been cancelled
pytest / Distributed (distributed_c) (push) Has been cancelled
pytest / Distributed (distributed_d) (push) Has been cancelled
pytest / Distributed (distributed_e) (push) Has been cancelled
pytest / Distributed (distributed_f) (push) Has been cancelled
pytest / Minimal Install (push) Has been cancelled
pytest / Event File (push) Has been cancelled
pytest (slow) / py-slow (push) Has been cancelled
Publish JSON Schema / publish-schema (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:49:20 +08:00

57 行
1.6 KiB
Python

from ludwig.api_annotations import DeveloperAPI
from ludwig.utils.registry import Registry
###
# Registry for augmentation operations
# Each augmentation operation is registered with the feature type it is applicable to
# and the name of the operation.
###
_augmentation_op_registry = Registry()
@DeveloperAPI
def get_augmentation_op_registry() -> Registry:
return _augmentation_op_registry
@DeveloperAPI
def register_augmentation_op(name: str, features: str | list[str]):
if isinstance(features, str):
features = [features]
def wrap(cls):
for feature in features:
augmentation_op_registry = get_augmentation_op_registry().get(feature, {})
augmentation_op_registry[name] = cls
get_augmentation_op_registry()[feature] = augmentation_op_registry
return cls
return wrap
@DeveloperAPI
def get_augmentation_op(feature_type: str, op_name: str):
return get_augmentation_op_registry()[feature_type][op_name]
class AugmentationPipelines:
"""Container holding augmentation pipelines defined in the model."""
def __init__(self, augmentation_pipelines: dict):
self.augmentation_pipelines = augmentation_pipelines
def __getitem__(self, key):
return self.augmentation_pipelines[key]
def __contains__(self, key):
return key in self.augmentation_pipelines
def __len__(self):
return len(self.augmentation_pipelines)
def __iter__(self):
return self.augmentation_pipelines.__iter__()
def items(self):
return self.augmentation_pipelines.items()