aiauto-client 0.1.7__py3-none-any.whl → 0.1.9__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/core.py CHANGED
@@ -31,8 +31,16 @@ class AIAutoController:
31
31
  if not host_external:
32
32
  raise RuntimeError("No storage host returned from EnsureWorkspace")
33
33
 
34
- host, port = host_external.split(':')
35
- self.storage = optuna.storages.GrpcStorageProxy(host=host, port=int(port))
34
+ # Parse host and port
35
+ if ':' in host_external:
36
+ host, port_str = host_external.rsplit(':', 1)
37
+ port = int(port_str)
38
+ else:
39
+ host = host_external
40
+ port = 443 # Default to HTTPS port
41
+
42
+ # Create storage with TLS support for port 443
43
+ self.storage = self._create_storage_with_tls(host, port)
36
44
 
37
45
  # Store the internal host for CRD usage (if needed later)
38
46
  self.storage_host_internal = response.get('journalGrpcStorageProxyHostInternal', '')
@@ -49,6 +57,74 @@ class AIAutoController:
49
57
  self.artifact_store = optuna.artifacts.FileSystemArtifactStore('./artifacts')
50
58
  self.tmp_dir = tempfile.mkdtemp(prefix=f'ai_auto_tmp_')
51
59
 
60
+ def _create_storage_with_tls(self, host: str, port: int):
61
+ """Create GrpcStorageProxy with automatic TLS detection based on port"""
62
+ # Port 13000 = internal (plain), Port 443 = external (TLS)
63
+ if port != 443:
64
+ # Plain gRPC for internal connections
65
+ return optuna.storages.GrpcStorageProxy(host=host, port=port)
66
+
67
+ # TLS connection for external access (port 443)
68
+ import grpc
69
+ creds = grpc.ssl_channel_credentials()
70
+
71
+ # Try different TLS parameter names for Optuna version compatibility
72
+ # Try 1: channel_credentials parameter (newer Optuna versions)
73
+ try:
74
+ return optuna.storages.GrpcStorageProxy(
75
+ host=host,
76
+ port=port,
77
+ channel_credentials=creds
78
+ )
79
+ except TypeError:
80
+ pass
81
+
82
+ # Try 2: ssl boolean parameter
83
+ try:
84
+ return optuna.storages.GrpcStorageProxy(
85
+ host=host,
86
+ port=port,
87
+ ssl=True
88
+ )
89
+ except TypeError:
90
+ pass
91
+
92
+ # Try 3: use_tls parameter
93
+ try:
94
+ return optuna.storages.GrpcStorageProxy(
95
+ host=host,
96
+ port=port,
97
+ use_tls=True
98
+ )
99
+ except TypeError:
100
+ pass
101
+
102
+ # Try 4: secure parameter
103
+ try:
104
+ return optuna.storages.GrpcStorageProxy(
105
+ host=host,
106
+ port=port,
107
+ secure=True
108
+ )
109
+ except TypeError:
110
+ pass
111
+
112
+ # Fallback: try to create secure channel manually
113
+ try:
114
+ channel = grpc.secure_channel(f"{host}:{port}", creds)
115
+ # Some Optuna versions might accept a channel directly
116
+ return optuna.storages.GrpcStorageProxy(channel=channel)
117
+ except (TypeError, AttributeError):
118
+ pass
119
+
120
+ # If all attempts fail, raise informative error
121
+ raise RuntimeError(
122
+ f"Failed to create TLS connection to {host}:{port}. "
123
+ "GrpcStorageProxy TLS parameters not recognized. "
124
+ "Please check Optuna version compatibility. "
125
+ "Tried: channel_credentials, ssl, use_tls, secure, channel parameters."
126
+ )
127
+
52
128
  def get_storage(self):
53
129
  return self.storage
54
130
 
@@ -172,7 +248,7 @@ class StudyWrapper:
172
248
  self._study = optuna.create_study(
173
249
  study_name=self.study_name,
174
250
  storage=self._storage,
175
- load_if_exists=True
251
+ load_if_exists=True,
176
252
  )
177
253
  except Exception as e:
178
254
  raise RuntimeError(
@@ -202,7 +278,8 @@ class StudyWrapper:
202
278
  request_data = {
203
279
  "objective": {
204
280
  "sourceCode": serialize(objective),
205
- "requirementsTxt": build_requirements(requirements_file, requirements_list)
281
+ "requirementsTxt": build_requirements(requirements_file, requirements_list),
282
+ "objectiveName": objective.__name__ # 함수명 추출하여 전달
206
283
  },
207
284
  "batch": {
208
285
  "studyName": self.study_name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiauto-client
3
- Version: 0.1.7
3
+ Version: 0.1.9
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
@@ -94,6 +94,17 @@ study_wrapper.optimize(
94
94
  runtime_image=aiauto.RUNTIME_IMAGES[0],
95
95
  )
96
96
  ```
97
+ - 종료 됐는지 optuna-dashboard 가 아닌 코드로 확인하는 법
98
+ ```python
99
+ study_wrapper.get_status()
100
+ # {'study_name': 'test', 'count_active': 0, 'count_succeeded': 10, 'count_pruned': 0, 'count_failed': 0, 'count_total': 10, 'count_completed': 10, 'dashboard_url': 'https://optuna-dashboard-10f804bb-52be-48e8-aa06-9f5411ed4b0d.aiauto.pangyo.ainode.ai', 'last_error': '', 'updated_at': '2025-09-01T11:31:49.375Z'}
101
+ while study_wrapper.get_status()['count_completed'] <= study_wrapper.get_status()['count_total']:
102
+ sleep(10) # 10초 마다 한 번 씩
103
+ ```
104
+ - best trial 을 가져오는 법
105
+ ```python
106
+ TODO
107
+ ```
97
108
 
98
109
  ## Jupyter Notebook 사용 시 주의사항
99
110
 
@@ -1,10 +1,10 @@
1
1
  aiauto/__init__.py,sha256=sF7sJaXg7-MqolSYLxsaXAir1dBzARhXLrHo7zLsupg,345
2
2
  aiauto/_config.py,sha256=DaRTIZlph9T3iuW-Cy4fkw8i3bXB--gMtW947SLZZNs,159
3
3
  aiauto/constants.py,sha256=rBibGOQHHrdkwaai92-3I8-N0cu-B4CoCoQbG9-Cl8k,821
4
- aiauto/core.py,sha256=DQW9uvVNqP9J9s1IFx969upw10NQLHJMNsudHnauk6A,9840
4
+ aiauto/core.py,sha256=caGUQEi4KTaov7Brak7o3O_27LZDNdYqUWmXDpusQaU,12553
5
5
  aiauto/http_client.py,sha256=t1gxeM5-d5bsVoFWgaNcTrt_WWUXuMuxge9gDlEqhoA,2086
6
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,,
7
+ aiauto_client-0.1.9.dist-info/METADATA,sha256=sIl-_c3kOSgxyO2wL3apNAK5_5t5KRZoBPCIeBkoxz8,19071
8
+ aiauto_client-0.1.9.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
9
+ aiauto_client-0.1.9.dist-info/top_level.txt,sha256=Sk2ctO9_Bf_tAPwq1x6Vfl6OuL29XzwMTO4F_KG6oJE,7
10
+ aiauto_client-0.1.9.dist-info/RECORD,,