aiauto-client 0.1.4__tar.gz → 0.1.5__tar.gz

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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiauto-client
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: AI Auto HPO (Hyperparameter Optimization) Client Library
5
5
  Author-email: AIAuto Team <ainode@zeroone.ai>
6
6
  Project-URL: Homepage, https://aiauto.cloude.ainode.ai
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "aiauto-client"
7
- version = "0.1.4"
7
+ version = "0.1.5"
8
8
  description = "AI Auto HPO (Hyperparameter Optimization) Client Library"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -1,5 +1,4 @@
1
1
  from .core import AIAutoController, TrialController, CallbackTopNArtifact, StudyWrapper
2
- from .api import create_study
3
2
  from ._config import AIAUTO_API_TARGET
4
3
  from .constants import RUNTIME_IMAGES
5
4
 
@@ -10,7 +9,6 @@ __all__ = [
10
9
  'TrialController',
11
10
  'CallbackTopNArtifact',
12
11
  'StudyWrapper',
13
- 'create_study',
14
12
  'AIAUTO_API_TARGET',
15
13
  'RUNTIME_IMAGES',
16
14
  ]
@@ -3,7 +3,7 @@ import tempfile
3
3
  from typing import Union, Optional, List, Dict, Callable
4
4
  import optuna
5
5
  from .http_client import ConnectRPCClient
6
- from .serializer import serialize, build_requirements
6
+ from .serializer import serialize, build_requirements, object_to_json
7
7
  from ._config import AIAUTO_API_TARGET
8
8
 
9
9
 
@@ -62,6 +62,46 @@ class AIAutoController:
62
62
  def get_artifact_tmp_dir(self):
63
63
  return self.tmp_dir
64
64
 
65
+ def create_study(
66
+ self,
67
+ study_name: str,
68
+ direction: Optional[str] = None,
69
+ directions: Optional[List[str]] = None,
70
+ sampler: Union[object, dict, None] = None,
71
+ pruner: Union[object, dict, None] = None
72
+ ) -> 'StudyWrapper':
73
+ """Create a new study using the controller's token."""
74
+ if not direction and not directions:
75
+ raise ValueError("Either 'direction' or 'directions' must be specified")
76
+
77
+ if direction and directions:
78
+ raise ValueError("Cannot specify both 'direction' and 'directions'")
79
+
80
+ try:
81
+ # Prepare request data for CreateStudy
82
+ request_data = {
83
+ "spec": {
84
+ "studyName": study_name,
85
+ "direction": direction or "",
86
+ "directions": directions or [],
87
+ "samplerJson": object_to_json(sampler),
88
+ "prunerJson": object_to_json(pruner)
89
+ }
90
+ }
91
+
92
+ # Call CreateStudy RPC
93
+ response = self.client.call_rpc("CreateStudy", request_data)
94
+
95
+ # Return StudyWrapper
96
+ return StudyWrapper(
97
+ study_name=response.get("studyName", study_name),
98
+ storage=self.storage,
99
+ controller=self
100
+ )
101
+
102
+ except Exception as e:
103
+ raise RuntimeError(f"Failed to create study: {e}") from e
104
+
65
105
 
66
106
  class TrialController:
67
107
  def __init__(self, trial: optuna.trial.Trial):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiauto-client
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: AI Auto HPO (Hyperparameter Optimization) Client Library
5
5
  Author-email: AIAuto Team <ainode@zeroone.ai>
6
6
  Project-URL: Homepage, https://aiauto.cloude.ainode.ai
@@ -2,7 +2,6 @@ README.md
2
2
  pyproject.toml
3
3
  src/aiauto/__init__.py
4
4
  src/aiauto/_config.py
5
- src/aiauto/api.py
6
5
  src/aiauto/constants.py
7
6
  src/aiauto/core.py
8
7
  src/aiauto/http_client.py
@@ -1,46 +0,0 @@
1
- from typing import Optional, List, Union
2
- from .serializer import object_to_json
3
- from .core import StudyWrapper, AIAutoController
4
-
5
-
6
- def create_study(
7
- study_name: str,
8
- token: str,
9
- direction: Optional[str] = None,
10
- directions: Optional[List[str]] = None,
11
- sampler: Union[object, dict, None] = None,
12
- pruner: Union[object, dict, None] = None
13
- ) -> StudyWrapper:
14
- if not direction and not directions:
15
- raise ValueError("Either 'direction' or 'directions' must be specified")
16
-
17
- if direction and directions:
18
- raise ValueError("Cannot specify both 'direction' and 'directions'")
19
-
20
- try:
21
- # Initialize controller (which ensures workspace)
22
- controller = AIAutoController(token)
23
-
24
- # Prepare request data for CreateStudy
25
- request_data = {
26
- "spec": {
27
- "studyName": study_name,
28
- "direction": direction or "",
29
- "directions": directions or [],
30
- "samplerJson": object_to_json(sampler),
31
- "prunerJson": object_to_json(pruner)
32
- }
33
- }
34
-
35
- # Call CreateStudy RPC
36
- response = controller.client.call_rpc("CreateStudy", request_data)
37
-
38
- # Return StudyWrapper
39
- return StudyWrapper(
40
- study_name=response.get("studyName", study_name),
41
- storage=controller.storage,
42
- controller=controller
43
- )
44
-
45
- except Exception as e:
46
- raise RuntimeError(f"Failed to create study: {e}") from e
File without changes
File without changes