• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IBM / unitxt / 14903020140

08 May 2025 09:14AM UTC coverage: 80.091% (-0.05%) from 80.14%
14903020140

Pull #1778

github

web-flow
Merge b61299f43 into 2d15f20af
Pull Request #1778: Add support to mix args and textual query in load_dataset

1642 of 2037 branches covered (80.61%)

Branch coverage included in aggregate %.

10270 of 12836 relevant lines covered (80.01%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.59
src/unitxt/dataset_utils.py
1
from json.decoder import JSONDecodeError
1✔
2
from typing import Any, Dict, Optional
1✔
3

4
from .artifact import Artifact, UnitxtArtifactNotFoundError, fetch_artifact
1✔
5
from .logging_utils import get_logger
1✔
6
from .parsing_utils import parse_key_equals_value_string_to_dict
1✔
7
from .register import _reset_env_local_catalogs, register_all_artifacts
1✔
8
from .settings_utils import get_settings
1✔
9
from .standard import DatasetRecipe
1✔
10

11
logger = get_logger()
1✔
12
settings = get_settings()
1✔
13

14

15
def fetch(artifact_name: str, overwrite_kwargs: Optional[Dict[str, Any]]=None):
1✔
16
    try:
1✔
17
        artifact, _ = fetch_artifact(artifact_name, overwrite_kwargs=overwrite_kwargs)
1✔
18
        return artifact
×
19
    except (UnitxtArtifactNotFoundError, JSONDecodeError):
1✔
20
        return None
1✔
21

22

23
def parse(query: str) -> dict:
1✔
24
    return parse_key_equals_value_string_to_dict(query)
1✔
25

26

27
def get_dataset_artifact(dataset, overwrite_kwargs: Optional[Dict[str, Any]]=None):
1✔
28
    if isinstance(dataset, DatasetRecipe):
1✔
29
        return dataset
×
30
    assert isinstance(
1✔
31
        dataset, str
32
    ), "dataset should be string description of recipe, or recipe object."
33
    _reset_env_local_catalogs()
1✔
34
    register_all_artifacts()
1✔
35
    recipe = fetch(dataset, overwrite_kwargs=overwrite_kwargs)
1✔
36
    if recipe is None:
1✔
37
        args = parse(dataset)
1✔
38
        if "__type__" not in args:
1✔
39
            args["__type__"] = settings.default_recipe
1✔
40
        if overwrite_kwargs is not None:
1✔
41
            args.update(overwrite_kwargs)
1✔
42
        recipe = Artifact.from_dict(args)
1✔
43
    return recipe
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc