hafnia 0.5.1__py3-none-any.whl → 0.5.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  from pathlib import Path
2
- from typing import Optional
2
+ from typing import Dict, Optional
3
3
 
4
4
  import click
5
5
 
@@ -21,12 +21,60 @@ def cmd_list_trainer_packages(cfg: Config, limit: Optional[int]) -> None:
21
21
 
22
22
  from hafnia.platform.trainer_package import get_trainer_packages, pretty_print_trainer_packages
23
23
 
24
- endpoint = cfg.get_platform_endpoint("trainers")
25
- trainers = get_trainer_packages(endpoint, cfg.api_key)
24
+ trainers = get_trainer_packages(cfg=cfg)
26
25
 
27
26
  pretty_print_trainer_packages(trainers, limit=limit)
28
27
 
29
28
 
29
+ @trainer_package.command(name="create")
30
+ @click.pass_obj
31
+ @click.argument(
32
+ "path",
33
+ type=Path,
34
+ )
35
+ @click.option(
36
+ "-n",
37
+ "--name",
38
+ type=str,
39
+ default=None,
40
+ help="Name of the trainer package.",
41
+ )
42
+ @click.option(
43
+ "-d",
44
+ "--description",
45
+ type=str,
46
+ default=None,
47
+ help="Description of the trainer package.",
48
+ )
49
+ @click.option(
50
+ "--cmd",
51
+ type=Optional[str],
52
+ default=None,
53
+ show_default=True,
54
+ help="Default command to run the trainer package.",
55
+ )
56
+ def cmd_create_trainer_package(
57
+ cfg: Config,
58
+ path: Path,
59
+ cmd: Optional[str] = None,
60
+ name: Optional[str] = None,
61
+ description: Optional[str] = None,
62
+ ) -> Dict:
63
+ """Create a trainer package on the platform"""
64
+ from hafnia.platform.trainer_package import create_trainer_package
65
+
66
+ path_trainer = Path(path).resolve()
67
+ trainer_response = create_trainer_package(
68
+ source_dir=path_trainer,
69
+ name=name,
70
+ description=description,
71
+ cmd=cmd,
72
+ cfg=cfg,
73
+ )
74
+
75
+ return trainer_response
76
+
77
+
30
78
  @trainer_package.command(name="create-zip")
31
79
  @click.argument("source")
32
80
  @click.option(
@@ -46,7 +94,7 @@ def cmd_create_trainer_package_zip(source: str, output: str) -> None:
46
94
  raise click.ClickException(consts.ERROR_TRAINER_PACKAGE_FILE_FORMAT)
47
95
 
48
96
  path_source = Path(source)
49
- path_output_zip = archive_dir(path_source, path_output_zip)
97
+ path_output_zip, _ = archive_dir(path_source, path_output_zip)
50
98
 
51
99
 
52
100
  @trainer_package.command(name="view-zip")
hafnia/data/__init__.py DELETED
@@ -1,3 +0,0 @@
1
- from hafnia.data.factory import get_dataset_path, load_dataset
2
-
3
- __all__ = ["load_dataset", "get_dataset_path"]
hafnia/data/factory.py DELETED
@@ -1,22 +0,0 @@
1
- from pathlib import Path
2
- from typing import Any
3
-
4
- from hafnia import utils
5
- from hafnia.dataset.hafnia_dataset import HafniaDataset, get_or_create_dataset_path_from_recipe
6
-
7
-
8
- def load_dataset(recipe: Any, force_redownload: bool = False) -> HafniaDataset:
9
- """Load a dataset either from a local path or from the Hafnia platform."""
10
-
11
- path_dataset = get_dataset_path(recipe, force_redownload=force_redownload)
12
- dataset = HafniaDataset.from_path(path_dataset)
13
- return dataset
14
-
15
-
16
- def get_dataset_path(recipe: Any, force_redownload: bool = False) -> Path:
17
- if utils.is_hafnia_cloud_job():
18
- return utils.get_dataset_path_in_hafnia_cloud()
19
-
20
- path_dataset = get_or_create_dataset_path_from_recipe(recipe, force_redownload=force_redownload)
21
-
22
- return path_dataset
File without changes
File without changes
File without changes