aiauto-client 0.1.6__py3-none-any.whl → 0.1.7__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.
- aiauto/serializer.py +20 -10
- {aiauto_client-0.1.6.dist-info → aiauto_client-0.1.7.dist-info}/METADATA +36 -3
- {aiauto_client-0.1.6.dist-info → aiauto_client-0.1.7.dist-info}/RECORD +5 -5
- {aiauto_client-0.1.6.dist-info → aiauto_client-0.1.7.dist-info}/WHEEL +0 -0
- {aiauto_client-0.1.6.dist-info → aiauto_client-0.1.7.dist-info}/top_level.txt +0 -0
aiauto/serializer.py
CHANGED
@@ -6,14 +6,24 @@ from typing import Callable, Union, List, Optional
|
|
6
6
|
def serialize(objective: Callable) -> str:
|
7
7
|
try:
|
8
8
|
return inspect.getsource(objective)
|
9
|
-
except
|
10
|
-
raise ValueError(
|
9
|
+
except (OSError, TypeError) as e:
|
10
|
+
raise ValueError(
|
11
|
+
"Serialize 실패 objective 함수는 파일로 저장되어야 합니다\n"
|
12
|
+
"REPL/Jupyter Notebook에서는 %%writefile magic을 사용해서 local 에 file 로 저장하세요\n\n"
|
13
|
+
"%%writefile objective.py\n"
|
14
|
+
"def objective(trial):\n"
|
15
|
+
" # 함수 내용\n"
|
16
|
+
" ...\n\n"
|
17
|
+
"그 다음:\n"
|
18
|
+
"from objective import objective\n"
|
19
|
+
"study.optimize(objective, ...)"
|
20
|
+
) from e
|
11
21
|
|
12
22
|
|
13
23
|
def build_requirements(file_path: Optional[str] = None, reqs: Optional[List[str]] = None) -> str:
|
14
24
|
if file_path and reqs:
|
15
25
|
raise ValueError("requirements_file과 requirements_list는 동시에 지정할 수 없습니다")
|
16
|
-
|
26
|
+
|
17
27
|
if file_path:
|
18
28
|
with open(file_path, 'r') as f:
|
19
29
|
return f.read()
|
@@ -26,20 +36,20 @@ def build_requirements(file_path: Optional[str] = None, reqs: Optional[List[str]
|
|
26
36
|
def object_to_json(obj: Union[object, dict, None]) -> str:
|
27
37
|
if obj is None:
|
28
38
|
return ""
|
29
|
-
|
39
|
+
|
30
40
|
if isinstance(obj, dict):
|
31
41
|
return json.dumps(obj)
|
32
|
-
|
42
|
+
|
33
43
|
cls = type(obj)
|
34
44
|
module_name = cls.__module__
|
35
45
|
class_name = cls.__name__
|
36
|
-
|
46
|
+
|
37
47
|
if not module_name.startswith('optuna.'):
|
38
48
|
raise ValueError(f"optuna 코어 클래스만 지원합니다: {class_name}")
|
39
|
-
|
49
|
+
|
40
50
|
sig = inspect.signature(cls)
|
41
51
|
kwargs = {}
|
42
|
-
|
52
|
+
|
43
53
|
for param_name, param in sig.parameters.items():
|
44
54
|
if param_name == 'self':
|
45
55
|
continue
|
@@ -47,9 +57,9 @@ def object_to_json(obj: Union[object, dict, None]) -> str:
|
|
47
57
|
value = getattr(obj, param_name)
|
48
58
|
if param.default != value:
|
49
59
|
kwargs[param_name] = value
|
50
|
-
|
60
|
+
|
51
61
|
return json.dumps({
|
52
62
|
"module": module_name,
|
53
63
|
"class": class_name,
|
54
64
|
"kwargs": kwargs
|
55
|
-
})
|
65
|
+
})
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: aiauto-client
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.7
|
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://dashboard.aiauto.pangyo.ainode.ai
|
@@ -50,8 +50,8 @@ AIAuto는 Kubernetes 기반의 분산 HPO(Hyperparameter Optimization) 시스템
|
|
50
50
|
- `parallelism` (int): 동시 실행 Pod 수 (기본값: 2)
|
51
51
|
- `requirements_file` (str): requirements.txt 파일 경로 (requirements_list와 상호 배타적)
|
52
52
|
- `requirements_list` (List[str]): 패키지 리스트 (requirements_file과 상호 배타적)
|
53
|
-
- `resources_requests` (Dict[str, str]):
|
54
|
-
- `resources_limits` (Dict[str, str]):
|
53
|
+
- `resources_requests` (Dict[str, str]): 리소스 요청 (기본값: {"cpu": "256m", "memory": "256Mi"})
|
54
|
+
- `resources_limits` (Dict[str, str]): 리소스 제한 (기본값: {"cpu": "256m", "memory": "256Mi"})
|
55
55
|
- `runtime_image` (str): 커스텀 런타임 이미지 (None이면 자동 선택)
|
56
56
|
- `use_gpu` (bool): GPU 사용 여부 (기본값: False)
|
57
57
|
|
@@ -95,6 +95,39 @@ study_wrapper.optimize(
|
|
95
95
|
)
|
96
96
|
```
|
97
97
|
|
98
|
+
## Jupyter Notebook 사용 시 주의사항
|
99
|
+
|
100
|
+
Jupyter Notebook이나 Python REPL에서 정의한 함수는 Serialize 할 수 없습니다
|
101
|
+
대신 `%%writefile` magic 울 사용하여 파일로 저장한 후 import 하세요.
|
102
|
+
|
103
|
+
### Jupyter에서 objective 함수 작성 방법
|
104
|
+
- objective 함수를 파일로 저장
|
105
|
+
```python
|
106
|
+
%%writefile my_objective.py
|
107
|
+
import aiauto
|
108
|
+
import optuna
|
109
|
+
|
110
|
+
def objective(trial: optuna.trial.Trial):
|
111
|
+
"""
|
112
|
+
이 함수는 외부 서버에서 실행됩니다.
|
113
|
+
모든 import는 함수 내부에 작성하세요.
|
114
|
+
"""
|
115
|
+
import torch # 함수 내부에서 import
|
116
|
+
|
117
|
+
x = trial.suggest_float('x', -10, 10)
|
118
|
+
y = trial.suggest_float('y', -10, 10)
|
119
|
+
return (x - 2) ** 2 + (y - 3) ** 2
|
120
|
+
```
|
121
|
+
- 저장한 함수를 import해서 사용
|
122
|
+
```python
|
123
|
+
import aiauto
|
124
|
+
from my_objective import objective
|
125
|
+
|
126
|
+
ac = aiauto.AIAutoController('<token>')
|
127
|
+
study = ac.create_study('test', 'minimize')
|
128
|
+
study.optimize(objective, n_trials=10, parallelism=2)
|
129
|
+
```
|
130
|
+
|
98
131
|
## 빠른 시작
|
99
132
|
|
100
133
|
### 1. 간단한 예제 (수학 함수 최적화)
|
@@ -3,8 +3,8 @@ aiauto/_config.py,sha256=DaRTIZlph9T3iuW-Cy4fkw8i3bXB--gMtW947SLZZNs,159
|
|
3
3
|
aiauto/constants.py,sha256=rBibGOQHHrdkwaai92-3I8-N0cu-B4CoCoQbG9-Cl8k,821
|
4
4
|
aiauto/core.py,sha256=DQW9uvVNqP9J9s1IFx969upw10NQLHJMNsudHnauk6A,9840
|
5
5
|
aiauto/http_client.py,sha256=t1gxeM5-d5bsVoFWgaNcTrt_WWUXuMuxge9gDlEqhoA,2086
|
6
|
-
aiauto/serializer.py,sha256=
|
7
|
-
aiauto_client-0.1.
|
8
|
-
aiauto_client-0.1.
|
9
|
-
aiauto_client-0.1.
|
10
|
-
aiauto_client-0.1.
|
6
|
+
aiauto/serializer.py,sha256=KqQeH0xp4LQuZE6r8kzXQsWY6QgC3hqn8MSuWTt4QmU,1938
|
7
|
+
aiauto_client-0.1.7.dist-info/METADATA,sha256=xy8ZGkJYOwMUgA_8J4ag2mepwBzGZQwsyIOkMgQ8Cpw,18450
|
8
|
+
aiauto_client-0.1.7.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
9
|
+
aiauto_client-0.1.7.dist-info/top_level.txt,sha256=Sk2ctO9_Bf_tAPwq1x6Vfl6OuL29XzwMTO4F_KG6oJE,7
|
10
|
+
aiauto_client-0.1.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|