aiauto-client 0.1.9__tar.gz → 0.1.10__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.
Files changed (21) hide show
  1. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/PKG-INFO +138 -4
  2. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/README.md +134 -0
  3. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/pyproject.toml +4 -4
  4. aiauto_client-0.1.10/src/aiauto/_config.py +2 -0
  5. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/src/aiauto/core.py +4 -80
  6. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/src/aiauto/http_client.py +2 -2
  7. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/src/aiauto_client.egg-info/PKG-INFO +138 -4
  8. aiauto_client-0.1.9/src/aiauto/_config.py +0 -3
  9. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/MANIFEST.in +0 -0
  10. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/examples/example_torch_multiple_objective.py +0 -0
  11. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/examples/example_torch_single_objective.py +0 -0
  12. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/examples/simple_example.py +0 -0
  13. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/setup.cfg +0 -0
  14. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/src/aiauto/__init__.py +0 -0
  15. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/src/aiauto/constants.py +0 -0
  16. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/src/aiauto/serializer.py +0 -0
  17. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/src/aiauto_client.egg-info/SOURCES.txt +0 -0
  18. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/src/aiauto_client.egg-info/dependency_links.txt +0 -0
  19. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/src/aiauto_client.egg-info/requires.txt +0 -0
  20. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/src/aiauto_client.egg-info/top_level.txt +0 -0
  21. {aiauto_client-0.1.9 → aiauto_client-0.1.10}/tests/test_local_storage.py +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiauto-client
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: AI Auto HPO (Hyperparameter Optimization) Client Library
5
5
  Author-email: AIAuto Team <ainode@zeroone.ai>
6
- Project-URL: Homepage, https://dashboard.aiauto.pangyo.ainode.ai
7
- Project-URL: Repository, https://dashboard.aiauto.pangyo.ainode.ai
8
- Project-URL: Documentation, https://dashboard.aiauto.pangyo.ainode.ai
6
+ Project-URL: Homepage, https://dashboard.common.aiauto.pangyo.ainode.ai
7
+ Project-URL: Repository, https://dashboard.common.aiauto.pangyo.ainode.ai
8
+ Project-URL: Documentation, https://dashboard.common.aiauto.pangyo.ainode.ai
9
9
  Classifier: Development Status :: 3 - Alpha
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: Intended Audience :: Science/Research
@@ -481,3 +481,137 @@ study.tell(trial, ret)
481
481
  ```bash
482
482
  make build push
483
483
  ```
484
+
485
+
486
+ ## LLM을 위한 설명 (for code assistants / agents)
487
+
488
+ 이 섹션은 **코드 어시스턴트/에이전트**가 AIAuto를 자동으로 사용할 때 참고하는 규칙 모음입니다.
489
+ 사람 사용자는 위 본문 가이드를 우선적으로 따르세요.
490
+
491
+ ### 1) 목적과 사용 흐름 (요약)
492
+ - AIAuto는 **Optuna를 Kubernetes에서 분산 실행**하도록 해주는 Python 클라이언트입니다.
493
+ - 두 가지 흐름을 지원합니다:
494
+ 1) `StudyWrapper.optimize(...)` → 원격(K8s) 병렬 실행
495
+ 2) `StudyWrapper.get_study()` → 실제 `optuna.Study` 로드 후 **ask/tell** 직접 사용
496
+
497
+ ### 2) 네트워크/도메인 규칙 (필수)
498
+ - **Connect RPC (HTTPS/443)**: `https://api.aiauto.pangyo.ainode.ai`
499
+ - **Optuna Storage (gRPC, 평문 h2c/13000)**:
500
+ `{userID}.journal-grpc-storage-proxy.aiauto.pangyo.ainode.ai:13000`
501
+ → **항상 평문(h2c)**. 443/TLS 시도 **금지**.
502
+ - 대시보드(웹): `https://dashboard.aiauto.pangyo.ainode.ai`
503
+
504
+ ### 3) 호출 순서 (결정 트리)
505
+ 1) 컨트롤러 생성: `AIAutoController(token)` → 토큰 검증 & 워크스페이스/엔드포인트 획득
506
+ 2) 스터디 생성: `controller.create_study(study_name, direction=… | directions=[…])`
507
+ - 제약: `direction` **또는** `directions` 중 **하나만** 사용
508
+ 3) 분기:
509
+ - **분산 실행**: `study.optimize(objective, n_trials, parallelism, …)`
510
+ - **네이티브 제어**: `real = study.get_study()` 후 `real.ask() / real.tell(...)`
511
+
512
+ ### 4) 인자/작성 제약(LLM이 반드시 지킬 불변식)
513
+ - `direction` **XOR** `directions` (동시 지정 금지)
514
+ - `requirements_file` **XOR** `requirements_list` (동시 지정 금지)
515
+ - `objective` 작성 규칙:
516
+ - 모든 **import는 함수 내부**에 작성
517
+ - 함수 시그니처에 **타입 힌트 금지** (예: `trial: optuna.trial.Trial` 사용 금지)
518
+ - 로컬 파일 경로 의존 금지(원격에서 다운로드/생성)
519
+
520
+ ### 5) 최소 예제
521
+
522
+ #### (A) 분산 실행
523
+ ```python
524
+ import aiauto, optuna
525
+
526
+ controller = aiauto.AIAutoController('aiauto_xxx')
527
+ study = controller.create_study('exp1', direction='minimize')
528
+
529
+ def objective(trial):
530
+ import numpy as np
531
+ x = trial.suggest_float('x', -10, 10)
532
+ return (x - 1.23) ** 2
533
+
534
+ study.optimize(
535
+ objective,
536
+ n_trials=64,
537
+ parallelism=8,
538
+ requirements_list=['numpy'],
539
+ )
540
+ ```
541
+
542
+ #### (B) ask/tell (실제 optuna.Study 사용)
543
+ ```python
544
+ import aiauto, optuna
545
+
546
+ controller = aiauto.AIAutoController('aiauto_xxx')
547
+ sw = controller.create_study('manual', direction='minimize')
548
+
549
+ real = sw.get_study() # 실제 optuna.Study 로드 (gRPC: h2c 13000)
550
+ t = real.ask()
551
+ x = t.suggest_float('x', -10, 10)
552
+ real.tell(t, (x - 2) ** 2)
553
+ ```
554
+
555
+ ### 6) 에러 응답 템플릿(자동 응답 가이드)
556
+ - 초기화/토큰 문제 감지:
557
+ - “대시보드에서 토큰을 재발급한 뒤 다시 시도하세요: https://dashboard.aiauto.pangyo.ainode.ai”
558
+ - `get_study()` 연결 실패(스토리지 준비 전):
559
+ - “Workspace/Storage가 아직 준비 중일 수 있어요. 잠시 후 다시 시도하거나 대시보드에서 상태를 확인해 주세요.”
560
+
561
+ ### 7) 금지/주의 목록
562
+ - gRPC를 **443/TLS**로 붙이려는 시도 **금지** (항상 **13000/h2c**).
563
+ - `direction & directions`, `requirements_file & requirements_list` 동시 지정 **금지**.
564
+ - `objective`는 함수 내부 import, 타입 힌트 금지, 로컬 파일 경로 의존 금지.
565
+
566
+ ### 8) Optuna 호환성 (Sampler/Pruner & Study API)
567
+ - **Sampler/Pruner 호환**: `create_study()`에 **Optuna 원본** `sampler`/`pruner` 인스턴스를 그대로 전달하면 됩니다.
568
+ Study 생성 시 지정된 sampler/pruner는 **Optuna Journal Storage**에 저장되고, 원격 Pod에서 `optuna.load_study()`로 로드될 때 **자동으로 동일 설정이 적용**됩니다. 별도 복원 로직이 필요 없습니다.
569
+ - **네이티브 Study 사용**: `StudyWrapper.get_study()`는 **실제 `optuna.Study` 객체**를 반환합니다.
570
+ 따라서 `best_trial`, `best_trials`(다중 목적), `trials_dataframe()`, `get_trials()`, `ask()/tell()` 등 **Optuna API를 그대로** 사용할 수 있습니다.
571
+
572
+ **공식 문서 링크**
573
+ - Samplers: https://optuna.readthedocs.io/en/stable/reference/samplers/index.html
574
+ - Pruners: https://optuna.readthedocs.io/en/stable/reference/pruners.html
575
+ - Study API: https://optuna.readthedocs.io/en/stable/reference/generated/optuna.study.Study.html
576
+
577
+ #### 예시: Sampler/Pruner 그대로 사용
578
+ ```python
579
+ import optuna, aiauto
580
+
581
+ controller = aiauto.AIAutoController('aiauto_xxx')
582
+ study = controller.create_study(
583
+ study_name='cnn',
584
+ direction='minimize',
585
+ sampler=optuna.samplers.TPESampler(seed=42),
586
+ pruner=optuna.pruners.MedianPruner(n_startup_trials=5),
587
+ )
588
+
589
+ def objective(trial):
590
+ import numpy as np
591
+ lr = trial.suggest_float('lr', 1e-5, 1e-1, log=True)
592
+ return (np.log10(lr) + 2) ** 2
593
+
594
+ study.optimize(objective, n_trials=50, parallelism=4)
595
+ ```
596
+
597
+ #### 예시: get_study() 후 Optuna API 그대로 사용
598
+ ```python
599
+ # 실제 optuna.Study 로드
600
+ real = study.get_study()
601
+
602
+ # 단일 목적: best_trial
603
+ print('best value:', real.best_trial.value)
604
+ print('best params:', real.best_trial.params)
605
+
606
+ # (옵션) 다중 목적: Pareto front
607
+ # print(real.best_trials) # multi-objective일 때 사용
608
+
609
+ # 분석/시각화용 DataFrame
610
+ df = real.trials_dataframe(attrs=('number', 'value', 'params', 'state'))
611
+ print(df.head())
612
+
613
+ # 세밀 제어: ask/tell
614
+ t = real.ask()
615
+ x = t.suggest_float('x', -10, 10)
616
+ real.tell(t, (x - 1.23) ** 2)
617
+ ```
@@ -454,3 +454,137 @@ study.tell(trial, ret)
454
454
  ```bash
455
455
  make build push
456
456
  ```
457
+
458
+
459
+ ## LLM을 위한 설명 (for code assistants / agents)
460
+
461
+ 이 섹션은 **코드 어시스턴트/에이전트**가 AIAuto를 자동으로 사용할 때 참고하는 규칙 모음입니다.
462
+ 사람 사용자는 위 본문 가이드를 우선적으로 따르세요.
463
+
464
+ ### 1) 목적과 사용 흐름 (요약)
465
+ - AIAuto는 **Optuna를 Kubernetes에서 분산 실행**하도록 해주는 Python 클라이언트입니다.
466
+ - 두 가지 흐름을 지원합니다:
467
+ 1) `StudyWrapper.optimize(...)` → 원격(K8s) 병렬 실행
468
+ 2) `StudyWrapper.get_study()` → 실제 `optuna.Study` 로드 후 **ask/tell** 직접 사용
469
+
470
+ ### 2) 네트워크/도메인 규칙 (필수)
471
+ - **Connect RPC (HTTPS/443)**: `https://api.aiauto.pangyo.ainode.ai`
472
+ - **Optuna Storage (gRPC, 평문 h2c/13000)**:
473
+ `{userID}.journal-grpc-storage-proxy.aiauto.pangyo.ainode.ai:13000`
474
+ → **항상 평문(h2c)**. 443/TLS 시도 **금지**.
475
+ - 대시보드(웹): `https://dashboard.aiauto.pangyo.ainode.ai`
476
+
477
+ ### 3) 호출 순서 (결정 트리)
478
+ 1) 컨트롤러 생성: `AIAutoController(token)` → 토큰 검증 & 워크스페이스/엔드포인트 획득
479
+ 2) 스터디 생성: `controller.create_study(study_name, direction=… | directions=[…])`
480
+ - 제약: `direction` **또는** `directions` 중 **하나만** 사용
481
+ 3) 분기:
482
+ - **분산 실행**: `study.optimize(objective, n_trials, parallelism, …)`
483
+ - **네이티브 제어**: `real = study.get_study()` 후 `real.ask() / real.tell(...)`
484
+
485
+ ### 4) 인자/작성 제약(LLM이 반드시 지킬 불변식)
486
+ - `direction` **XOR** `directions` (동시 지정 금지)
487
+ - `requirements_file` **XOR** `requirements_list` (동시 지정 금지)
488
+ - `objective` 작성 규칙:
489
+ - 모든 **import는 함수 내부**에 작성
490
+ - 함수 시그니처에 **타입 힌트 금지** (예: `trial: optuna.trial.Trial` 사용 금지)
491
+ - 로컬 파일 경로 의존 금지(원격에서 다운로드/생성)
492
+
493
+ ### 5) 최소 예제
494
+
495
+ #### (A) 분산 실행
496
+ ```python
497
+ import aiauto, optuna
498
+
499
+ controller = aiauto.AIAutoController('aiauto_xxx')
500
+ study = controller.create_study('exp1', direction='minimize')
501
+
502
+ def objective(trial):
503
+ import numpy as np
504
+ x = trial.suggest_float('x', -10, 10)
505
+ return (x - 1.23) ** 2
506
+
507
+ study.optimize(
508
+ objective,
509
+ n_trials=64,
510
+ parallelism=8,
511
+ requirements_list=['numpy'],
512
+ )
513
+ ```
514
+
515
+ #### (B) ask/tell (실제 optuna.Study 사용)
516
+ ```python
517
+ import aiauto, optuna
518
+
519
+ controller = aiauto.AIAutoController('aiauto_xxx')
520
+ sw = controller.create_study('manual', direction='minimize')
521
+
522
+ real = sw.get_study() # 실제 optuna.Study 로드 (gRPC: h2c 13000)
523
+ t = real.ask()
524
+ x = t.suggest_float('x', -10, 10)
525
+ real.tell(t, (x - 2) ** 2)
526
+ ```
527
+
528
+ ### 6) 에러 응답 템플릿(자동 응답 가이드)
529
+ - 초기화/토큰 문제 감지:
530
+ - “대시보드에서 토큰을 재발급한 뒤 다시 시도하세요: https://dashboard.aiauto.pangyo.ainode.ai”
531
+ - `get_study()` 연결 실패(스토리지 준비 전):
532
+ - “Workspace/Storage가 아직 준비 중일 수 있어요. 잠시 후 다시 시도하거나 대시보드에서 상태를 확인해 주세요.”
533
+
534
+ ### 7) 금지/주의 목록
535
+ - gRPC를 **443/TLS**로 붙이려는 시도 **금지** (항상 **13000/h2c**).
536
+ - `direction & directions`, `requirements_file & requirements_list` 동시 지정 **금지**.
537
+ - `objective`는 함수 내부 import, 타입 힌트 금지, 로컬 파일 경로 의존 금지.
538
+
539
+ ### 8) Optuna 호환성 (Sampler/Pruner & Study API)
540
+ - **Sampler/Pruner 호환**: `create_study()`에 **Optuna 원본** `sampler`/`pruner` 인스턴스를 그대로 전달하면 됩니다.
541
+ Study 생성 시 지정된 sampler/pruner는 **Optuna Journal Storage**에 저장되고, 원격 Pod에서 `optuna.load_study()`로 로드될 때 **자동으로 동일 설정이 적용**됩니다. 별도 복원 로직이 필요 없습니다.
542
+ - **네이티브 Study 사용**: `StudyWrapper.get_study()`는 **실제 `optuna.Study` 객체**를 반환합니다.
543
+ 따라서 `best_trial`, `best_trials`(다중 목적), `trials_dataframe()`, `get_trials()`, `ask()/tell()` 등 **Optuna API를 그대로** 사용할 수 있습니다.
544
+
545
+ **공식 문서 링크**
546
+ - Samplers: https://optuna.readthedocs.io/en/stable/reference/samplers/index.html
547
+ - Pruners: https://optuna.readthedocs.io/en/stable/reference/pruners.html
548
+ - Study API: https://optuna.readthedocs.io/en/stable/reference/generated/optuna.study.Study.html
549
+
550
+ #### 예시: Sampler/Pruner 그대로 사용
551
+ ```python
552
+ import optuna, aiauto
553
+
554
+ controller = aiauto.AIAutoController('aiauto_xxx')
555
+ study = controller.create_study(
556
+ study_name='cnn',
557
+ direction='minimize',
558
+ sampler=optuna.samplers.TPESampler(seed=42),
559
+ pruner=optuna.pruners.MedianPruner(n_startup_trials=5),
560
+ )
561
+
562
+ def objective(trial):
563
+ import numpy as np
564
+ lr = trial.suggest_float('lr', 1e-5, 1e-1, log=True)
565
+ return (np.log10(lr) + 2) ** 2
566
+
567
+ study.optimize(objective, n_trials=50, parallelism=4)
568
+ ```
569
+
570
+ #### 예시: get_study() 후 Optuna API 그대로 사용
571
+ ```python
572
+ # 실제 optuna.Study 로드
573
+ real = study.get_study()
574
+
575
+ # 단일 목적: best_trial
576
+ print('best value:', real.best_trial.value)
577
+ print('best params:', real.best_trial.params)
578
+
579
+ # (옵션) 다중 목적: Pareto front
580
+ # print(real.best_trials) # multi-objective일 때 사용
581
+
582
+ # 분석/시각화용 DataFrame
583
+ df = real.trials_dataframe(attrs=('number', 'value', 'params', 'state'))
584
+ print(df.head())
585
+
586
+ # 세밀 제어: ask/tell
587
+ t = real.ask()
588
+ x = t.suggest_float('x', -10, 10)
589
+ real.tell(t, (x - 1.23) ** 2)
590
+ ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "aiauto-client"
7
- version = "0.1.9"
7
+ version = "0.1.10"
8
8
  description = "AI Auto HPO (Hyperparameter Optimization) Client Library"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -33,9 +33,9 @@ dependencies = [
33
33
  ]
34
34
 
35
35
  [project.urls]
36
- Homepage = "https://dashboard.aiauto.pangyo.ainode.ai"
37
- Repository = "https://dashboard.aiauto.pangyo.ainode.ai"
38
- Documentation = "https://dashboard.aiauto.pangyo.ainode.ai"
36
+ Homepage = "https://dashboard.common.aiauto.pangyo.ainode.ai"
37
+ Repository = "https://dashboard.common.aiauto.pangyo.ainode.ai"
38
+ Documentation = "https://dashboard.common.aiauto.pangyo.ainode.ai"
39
39
 
40
40
  [tool.setuptools.packages.find]
41
41
  where = ["src"]
@@ -0,0 +1,2 @@
1
+ # For Connect RPC over HTTP
2
+ AIAUTO_API_TARGET = "api.common.aiauto.pangyo.ainode.ai:443"
@@ -31,16 +31,8 @@ class AIAutoController:
31
31
  if not host_external:
32
32
  raise RuntimeError("No storage host returned from EnsureWorkspace")
33
33
 
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)
34
+ host, port = host_external.split(':')
35
+ self.storage = optuna.storages.GrpcStorageProxy(host=host, port=int(port))
44
36
 
45
37
  # Store the internal host for CRD usage (if needed later)
46
38
  self.storage_host_internal = response.get('journalGrpcStorageProxyHostInternal', '')
@@ -49,7 +41,7 @@ class AIAutoController:
49
41
  except Exception as e:
50
42
  raise RuntimeError(
51
43
  f"Failed to initialize workspace: {e}\n"
52
- "Please delete and reissue your token from the web dashboard at https://dashboard.aiauto.pangyo.ainode.ai"
44
+ "Please delete and reissue your token from the web dashboard at https://dashboard.common.aiauto.pangyo.ainode.ai"
53
45
  ) from e
54
46
 
55
47
  # artifact storage
@@ -57,74 +49,6 @@ class AIAutoController:
57
49
  self.artifact_store = optuna.artifacts.FileSystemArtifactStore('./artifacts')
58
50
  self.tmp_dir = tempfile.mkdtemp(prefix=f'ai_auto_tmp_')
59
51
 
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
-
128
52
  def get_storage(self):
129
53
  return self.storage
130
54
 
@@ -253,7 +177,7 @@ class StudyWrapper:
253
177
  except Exception as e:
254
178
  raise RuntimeError(
255
179
  "Failed to get study. If this persists, please delete and reissue your token "
256
- "from the web dashboard at https://dashboard.aiauto.pangyo.ainode.ai"
180
+ "from the web dashboard at https://dashboard.common.aiauto.pangyo.ainode.ai"
257
181
  ) from e
258
182
  return self._study
259
183
 
@@ -13,8 +13,8 @@ class ConnectRPCClient:
13
13
  if base_url:
14
14
  self.base_url = base_url
15
15
  else:
16
- # AIAUTO_API_TARGET is like "api.aiauto.pangyo.ainode.ai:443"
17
- # Convert to "https://api.aiauto.pangyo.ainode.ai"
16
+ # AIAUTO_API_TARGET is like "api.common.aiauto.pangyo.ainode.ai:443"
17
+ # Convert to "https://api.common.aiauto.pangyo.ainode.ai"
18
18
  host = AIAUTO_API_TARGET.split(':')[0]
19
19
  self.base_url = f"https://{host}"
20
20
 
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiauto-client
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: AI Auto HPO (Hyperparameter Optimization) Client Library
5
5
  Author-email: AIAuto Team <ainode@zeroone.ai>
6
- Project-URL: Homepage, https://dashboard.aiauto.pangyo.ainode.ai
7
- Project-URL: Repository, https://dashboard.aiauto.pangyo.ainode.ai
8
- Project-URL: Documentation, https://dashboard.aiauto.pangyo.ainode.ai
6
+ Project-URL: Homepage, https://dashboard.common.aiauto.pangyo.ainode.ai
7
+ Project-URL: Repository, https://dashboard.common.aiauto.pangyo.ainode.ai
8
+ Project-URL: Documentation, https://dashboard.common.aiauto.pangyo.ainode.ai
9
9
  Classifier: Development Status :: 3 - Alpha
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: Intended Audience :: Science/Research
@@ -481,3 +481,137 @@ study.tell(trial, ret)
481
481
  ```bash
482
482
  make build push
483
483
  ```
484
+
485
+
486
+ ## LLM을 위한 설명 (for code assistants / agents)
487
+
488
+ 이 섹션은 **코드 어시스턴트/에이전트**가 AIAuto를 자동으로 사용할 때 참고하는 규칙 모음입니다.
489
+ 사람 사용자는 위 본문 가이드를 우선적으로 따르세요.
490
+
491
+ ### 1) 목적과 사용 흐름 (요약)
492
+ - AIAuto는 **Optuna를 Kubernetes에서 분산 실행**하도록 해주는 Python 클라이언트입니다.
493
+ - 두 가지 흐름을 지원합니다:
494
+ 1) `StudyWrapper.optimize(...)` → 원격(K8s) 병렬 실행
495
+ 2) `StudyWrapper.get_study()` → 실제 `optuna.Study` 로드 후 **ask/tell** 직접 사용
496
+
497
+ ### 2) 네트워크/도메인 규칙 (필수)
498
+ - **Connect RPC (HTTPS/443)**: `https://api.aiauto.pangyo.ainode.ai`
499
+ - **Optuna Storage (gRPC, 평문 h2c/13000)**:
500
+ `{userID}.journal-grpc-storage-proxy.aiauto.pangyo.ainode.ai:13000`
501
+ → **항상 평문(h2c)**. 443/TLS 시도 **금지**.
502
+ - 대시보드(웹): `https://dashboard.aiauto.pangyo.ainode.ai`
503
+
504
+ ### 3) 호출 순서 (결정 트리)
505
+ 1) 컨트롤러 생성: `AIAutoController(token)` → 토큰 검증 & 워크스페이스/엔드포인트 획득
506
+ 2) 스터디 생성: `controller.create_study(study_name, direction=… | directions=[…])`
507
+ - 제약: `direction` **또는** `directions` 중 **하나만** 사용
508
+ 3) 분기:
509
+ - **분산 실행**: `study.optimize(objective, n_trials, parallelism, …)`
510
+ - **네이티브 제어**: `real = study.get_study()` 후 `real.ask() / real.tell(...)`
511
+
512
+ ### 4) 인자/작성 제약(LLM이 반드시 지킬 불변식)
513
+ - `direction` **XOR** `directions` (동시 지정 금지)
514
+ - `requirements_file` **XOR** `requirements_list` (동시 지정 금지)
515
+ - `objective` 작성 규칙:
516
+ - 모든 **import는 함수 내부**에 작성
517
+ - 함수 시그니처에 **타입 힌트 금지** (예: `trial: optuna.trial.Trial` 사용 금지)
518
+ - 로컬 파일 경로 의존 금지(원격에서 다운로드/생성)
519
+
520
+ ### 5) 최소 예제
521
+
522
+ #### (A) 분산 실행
523
+ ```python
524
+ import aiauto, optuna
525
+
526
+ controller = aiauto.AIAutoController('aiauto_xxx')
527
+ study = controller.create_study('exp1', direction='minimize')
528
+
529
+ def objective(trial):
530
+ import numpy as np
531
+ x = trial.suggest_float('x', -10, 10)
532
+ return (x - 1.23) ** 2
533
+
534
+ study.optimize(
535
+ objective,
536
+ n_trials=64,
537
+ parallelism=8,
538
+ requirements_list=['numpy'],
539
+ )
540
+ ```
541
+
542
+ #### (B) ask/tell (실제 optuna.Study 사용)
543
+ ```python
544
+ import aiauto, optuna
545
+
546
+ controller = aiauto.AIAutoController('aiauto_xxx')
547
+ sw = controller.create_study('manual', direction='minimize')
548
+
549
+ real = sw.get_study() # 실제 optuna.Study 로드 (gRPC: h2c 13000)
550
+ t = real.ask()
551
+ x = t.suggest_float('x', -10, 10)
552
+ real.tell(t, (x - 2) ** 2)
553
+ ```
554
+
555
+ ### 6) 에러 응답 템플릿(자동 응답 가이드)
556
+ - 초기화/토큰 문제 감지:
557
+ - “대시보드에서 토큰을 재발급한 뒤 다시 시도하세요: https://dashboard.aiauto.pangyo.ainode.ai”
558
+ - `get_study()` 연결 실패(스토리지 준비 전):
559
+ - “Workspace/Storage가 아직 준비 중일 수 있어요. 잠시 후 다시 시도하거나 대시보드에서 상태를 확인해 주세요.”
560
+
561
+ ### 7) 금지/주의 목록
562
+ - gRPC를 **443/TLS**로 붙이려는 시도 **금지** (항상 **13000/h2c**).
563
+ - `direction & directions`, `requirements_file & requirements_list` 동시 지정 **금지**.
564
+ - `objective`는 함수 내부 import, 타입 힌트 금지, 로컬 파일 경로 의존 금지.
565
+
566
+ ### 8) Optuna 호환성 (Sampler/Pruner & Study API)
567
+ - **Sampler/Pruner 호환**: `create_study()`에 **Optuna 원본** `sampler`/`pruner` 인스턴스를 그대로 전달하면 됩니다.
568
+ Study 생성 시 지정된 sampler/pruner는 **Optuna Journal Storage**에 저장되고, 원격 Pod에서 `optuna.load_study()`로 로드될 때 **자동으로 동일 설정이 적용**됩니다. 별도 복원 로직이 필요 없습니다.
569
+ - **네이티브 Study 사용**: `StudyWrapper.get_study()`는 **실제 `optuna.Study` 객체**를 반환합니다.
570
+ 따라서 `best_trial`, `best_trials`(다중 목적), `trials_dataframe()`, `get_trials()`, `ask()/tell()` 등 **Optuna API를 그대로** 사용할 수 있습니다.
571
+
572
+ **공식 문서 링크**
573
+ - Samplers: https://optuna.readthedocs.io/en/stable/reference/samplers/index.html
574
+ - Pruners: https://optuna.readthedocs.io/en/stable/reference/pruners.html
575
+ - Study API: https://optuna.readthedocs.io/en/stable/reference/generated/optuna.study.Study.html
576
+
577
+ #### 예시: Sampler/Pruner 그대로 사용
578
+ ```python
579
+ import optuna, aiauto
580
+
581
+ controller = aiauto.AIAutoController('aiauto_xxx')
582
+ study = controller.create_study(
583
+ study_name='cnn',
584
+ direction='minimize',
585
+ sampler=optuna.samplers.TPESampler(seed=42),
586
+ pruner=optuna.pruners.MedianPruner(n_startup_trials=5),
587
+ )
588
+
589
+ def objective(trial):
590
+ import numpy as np
591
+ lr = trial.suggest_float('lr', 1e-5, 1e-1, log=True)
592
+ return (np.log10(lr) + 2) ** 2
593
+
594
+ study.optimize(objective, n_trials=50, parallelism=4)
595
+ ```
596
+
597
+ #### 예시: get_study() 후 Optuna API 그대로 사용
598
+ ```python
599
+ # 실제 optuna.Study 로드
600
+ real = study.get_study()
601
+
602
+ # 단일 목적: best_trial
603
+ print('best value:', real.best_trial.value)
604
+ print('best params:', real.best_trial.params)
605
+
606
+ # (옵션) 다중 목적: Pareto front
607
+ # print(real.best_trials) # multi-objective일 때 사용
608
+
609
+ # 분석/시각화용 DataFrame
610
+ df = real.trials_dataframe(attrs=('number', 'value', 'params', 'state'))
611
+ print(df.head())
612
+
613
+ # 세밀 제어: ask/tell
614
+ t = real.ask()
615
+ x = t.suggest_float('x', -10, 10)
616
+ real.tell(t, (x - 1.23) ** 2)
617
+ ```
@@ -1,3 +0,0 @@
1
- # For Connect RPC over HTTP
2
- # This will be converted to https://api.aiauto.pangyo.ainode.ai in production
3
- AIAUTO_API_TARGET = "api.aiauto.pangyo.ainode.ai:443"
File without changes