gyomu-cli 0.4.0__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.
gyomu_cli/__init__.py
ADDED
|
File without changes
|
gyomu_cli/main.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from gyomu_ai.provider.pydantic_ai.google import (
|
|
5
|
+
create_default_pydantic_ai_model_registry,
|
|
6
|
+
)
|
|
7
|
+
from gyomu_ai.provider.pydantic_ai.route_registry import AiConfiguration, initialize_ai
|
|
8
|
+
from gyomu_ai.provider.pydantic_ai.routing import (
|
|
9
|
+
ModelRoute,
|
|
10
|
+
ModelRouteId,
|
|
11
|
+
ModelRoutes,
|
|
12
|
+
RouteNode,
|
|
13
|
+
)
|
|
14
|
+
from gyomu_ai_compiler.pipelines.docstring_update import DocstringRouteId
|
|
15
|
+
from gyomu_infra.logger import logger
|
|
16
|
+
from gyomu_schema.option.retry import RetryObserver
|
|
17
|
+
from gyomu_workflow.snapshot.models import (
|
|
18
|
+
DocstringExecutionOption,
|
|
19
|
+
FileFilter,
|
|
20
|
+
SnapshotActionOption,
|
|
21
|
+
SnapshotExecutionOption,
|
|
22
|
+
SnapshotTargetOption,
|
|
23
|
+
)
|
|
24
|
+
from gyomu_workflow.snapshot.run import run_snapshot
|
|
25
|
+
from gyomu_workflow.snapshot.translate import translate_snapshot_request
|
|
26
|
+
from gyomu_workflow.snapshot.validate import validate_snapshot_request
|
|
27
|
+
from returns.result import Failure
|
|
28
|
+
|
|
29
|
+
app = typer.Typer()
|
|
30
|
+
|
|
31
|
+
hello_app = typer.Typer()
|
|
32
|
+
app.add_typer(hello_app, name="hello")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# @hello_app.command()
|
|
36
|
+
@app.command()
|
|
37
|
+
def greet(name: str = "World") -> None:
|
|
38
|
+
print(f"Hello, {name}!")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@app.command()
|
|
42
|
+
def greet2(name: str = "World") -> None:
|
|
43
|
+
print(f"Hello, {name}!")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@hello_app.command("greet")
|
|
47
|
+
def greet3(name: str = "World") -> None:
|
|
48
|
+
print(f"Hello, {name}!")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def register_google_routing(
|
|
52
|
+
route_id_list: list[ModelRouteId],
|
|
53
|
+
retry_observer: RetryObserver | None = None,
|
|
54
|
+
) -> None:
|
|
55
|
+
route: RouteNode = RouteNode(registry=create_default_pydantic_ai_model_registry())
|
|
56
|
+
routes: dict[ModelRouteId, ModelRoute] = {}
|
|
57
|
+
for route_id in route_id_list:
|
|
58
|
+
routes[route_id] = ModelRoute((route,))
|
|
59
|
+
initialize_ai(
|
|
60
|
+
AiConfiguration(
|
|
61
|
+
model_routes=ModelRoutes(routes=routes), retry_observer=retry_observer
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@app.command()
|
|
67
|
+
def snapshot(
|
|
68
|
+
package: str,
|
|
69
|
+
docstring: bool = True,
|
|
70
|
+
all: bool = False,
|
|
71
|
+
commit: bool = True,
|
|
72
|
+
filter: str | None = None,
|
|
73
|
+
log_keyword: str | None = None,
|
|
74
|
+
) -> None:
|
|
75
|
+
register_google_routing(route_id_list=[DocstringRouteId])
|
|
76
|
+
option = SnapshotExecutionOption(
|
|
77
|
+
commit=commit,
|
|
78
|
+
target=SnapshotTargetOption(
|
|
79
|
+
all=all,
|
|
80
|
+
file_filter=FileFilter(pattern=filter) if filter is not None else None,
|
|
81
|
+
),
|
|
82
|
+
action=SnapshotActionOption(
|
|
83
|
+
docstring=DocstringExecutionOption(
|
|
84
|
+
enabled=docstring, log_keyword=log_keyword
|
|
85
|
+
),
|
|
86
|
+
),
|
|
87
|
+
)
|
|
88
|
+
request_result = translate_snapshot_request(package, option)
|
|
89
|
+
if isinstance(request_result, Failure):
|
|
90
|
+
logger.error_object(request_result.failure())
|
|
91
|
+
return
|
|
92
|
+
request = request_result.unwrap()
|
|
93
|
+
logger.info(
|
|
94
|
+
f"commit: {request.option.commit}, "
|
|
95
|
+
f"docstring:{request.option.action.docstring.enabled}, "
|
|
96
|
+
f"all={request.option.target.all}"
|
|
97
|
+
)
|
|
98
|
+
if filter:
|
|
99
|
+
assert option.target.file_filter
|
|
100
|
+
logger.info(f"filter: {option.target.file_filter.pattern}")
|
|
101
|
+
if log_keyword:
|
|
102
|
+
logger.info(f"log_keyword: {request.option.action.docstring.log_keyword}")
|
|
103
|
+
|
|
104
|
+
validation_result = validate_snapshot_request(request)
|
|
105
|
+
if isinstance(validation_result, Failure):
|
|
106
|
+
logger.error_object(validation_result.failure())
|
|
107
|
+
return
|
|
108
|
+
|
|
109
|
+
snapshot_result = asyncio.run(run_snapshot(request))
|
|
110
|
+
if isinstance(snapshot_result, Failure):
|
|
111
|
+
logger.error_object(snapshot_result.failure())
|
|
112
|
+
return
|
|
113
|
+
|
|
114
|
+
logger.info("Done")
|
|
115
|
+
# logger.error_object(request.unwrap(), 3)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
if __name__ == "__main__":
|
|
119
|
+
app()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: gyomu-cli
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Gyomu CLI
|
|
5
|
+
Requires-Python: >=3.13
|
|
6
|
+
Requires-Dist: gyomu-infra
|
|
7
|
+
Requires-Dist: gyomu-schema
|
|
8
|
+
Requires-Dist: gyomu-workflow
|
|
9
|
+
Requires-Dist: returns
|
|
10
|
+
Requires-Dist: typer>=0.27.2
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# gyomu-cli
|
|
14
|
+
|
|
15
|
+
cli application for Gyomu Python.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
gyomu_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
gyomu_cli/main.py,sha256=jSYu9nS5_d83ZjQcR6gCMXxOOOoDYVthxy6M_lsZOn4,3518
|
|
3
|
+
gyomu_cli-0.4.0.dist-info/METADATA,sha256=SUe_GW8epZH2pfAuG-SriUZQAx-Gpd0zNpyfVbxj3WY,321
|
|
4
|
+
gyomu_cli-0.4.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
5
|
+
gyomu_cli-0.4.0.dist-info/entry_points.txt,sha256=gARZN75-4b-GrdG4D40P5rfrJs4gAoU7hyqZ6cFEamY,45
|
|
6
|
+
gyomu_cli-0.4.0.dist-info/RECORD,,
|