graphcore-distro 0.2.2__tar.gz → 0.2.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.
- {graphcore_distro-0.2.2/graphcore_distro.egg-info → graphcore_distro-0.2.5}/PKG-INFO +4 -3
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/doc_topics.py +10 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/__init__.py +30 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/api_cmd.py +14 -3
- graphcore_distro-0.2.5/graphcore_cli/baseline.py +70 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/docker_cmd.py +17 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/frontend_cmd.py +133 -21
- graphcore_distro-0.2.5/graphcore_cli/manifest_cmd.py +9 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/scaffold_cmd.py +156 -61
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_api_cmd.py +27 -2
- graphcore_distro-0.2.5/graphcore_cli/tests/test_baseline.py +252 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_cli.py +65 -7
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_frontend_cmd.py +157 -2
- graphcore_distro-0.2.5/graphcore_cli/tests/test_manifest_cmd.py +52 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_packaging.py +23 -0
- graphcore_distro-0.2.5/graphcore_cli/tests/test_upgrade_cmd.py +326 -0
- graphcore_distro-0.2.5/graphcore_cli/upgrade_cmd.py +266 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5/graphcore_distro.egg-info}/PKG-INFO +4 -3
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_distro.egg-info/SOURCES.txt +9 -0
- graphcore_distro-0.2.5/graphcore_distro.egg-info/requires.txt +4 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/__init__.py +2 -1
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/identity.py +17 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/keycloak_admin.py +11 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/runner.py +26 -8
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/tests/test_identity.py +40 -1
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/tests/test_runner.py +38 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/infra/realm/template-realm.json +4 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/persistence.py-tpl +1 -1
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/react_frontend/package.json +4 -3
- graphcore_distro-0.2.5/graphcore_project_kit/scaffold/project_template/.dockerignore +27 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/.env.example +3 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/.gitignore +1 -1
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/AGENTS.md +5 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/README.md +1 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/backend/project_name/settings.py-tpl +6 -1
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/agent_views.md +34 -13
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/app_design/app_tdd_template.md +2 -4
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/app_design/how_to_design_gc_apps.md +5 -2
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/app_design/stacks_tdd.md +8 -21
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/custom_authorization.md +25 -5
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/deployment_access.md +21 -14
- graphcore_distro-0.2.5/graphcore_user_guides/entities.md +482 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/frontend.md +140 -2
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/getting_started.md +9 -3
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/identity_infrastructure.md +9 -2
- graphcore_distro-0.2.5/graphcore_user_guides/manifests.md +96 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/production.md +8 -2
- graphcore_distro-0.2.5/graphcore_user_guides/upgrading.md +119 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/writing_strategies.md +120 -31
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/pyproject.toml +4 -3
- graphcore_distro-0.2.2/graphcore_distro.egg-info/requires.txt +0 -3
- graphcore_distro-0.2.2/graphcore_user_guides/entities.md +0 -281
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/LICENSE +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/NOTICE +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/README.md +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/apps_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/db_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/docs_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/identity_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/infra_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/skills_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/__init__.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_createadmin_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_dev_reset.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_docker_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_docs_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_infra_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_migrate.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_policy_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_skills_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_cli/tests/test_status_cmd.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_distro.egg-info/dependency_links.txt +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_distro.egg-info/entry_points.txt +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_distro.egg-info/top_level.txt +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/http.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/locate.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/tests/__init__.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/tests/test_keycloak_admin.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project/tests/test_locate.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/__init__.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/infra/docker-compose.yml +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/infra/realm/README.md +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/infra/themes/graphcore/login/template.ftl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/infra/themes/graphcore/login/theme.properties +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/__init__.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/apps.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/authorization.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/entities/__init__.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/migrations/__init__.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/models.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/routes.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/strategies/__init__.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/test_settings.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name/tests/__init__.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name_agent_frontend/__init__.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/app_name_agent_frontend/agent_views.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/backend/pyproject.toml +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/react_frontend/generated/README.md +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/react_frontend/index.ts-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/app_template/react_frontend/style.css-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/.mcp.json +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/CLAUDE.md +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/apps/.gitkeep +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/backend/Dockerfile +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/backend/manage.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/backend/project_name/__init__.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/backend/project_name/asgi.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/backend/project_name/urls.py-tpl +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/backend/requirements.txt +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/docker-compose.yml +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/package.json +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/react_frontend/index.html +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/react_frontend/package.json +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/react_frontend/src/App.tsx +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/react_frontend/src/generated/installedApps.css +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/react_frontend/src/generated/installedApps.ts +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/react_frontend/src/index.css +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/react_frontend/src/main.tsx +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/react_frontend/src/vite-env.d.ts +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/react_frontend/tsconfig.json +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scaffold/project_template/react_frontend/vite.config.ts +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scripts/backup_postgres.sh +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/scripts/restore_postgres.sh +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_project_kit/skills/graphcore-docs/SKILL.md +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/__init__.py +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/graphcore_user_guides/service_accounts.md +0 -0
- {graphcore_distro-0.2.2 → graphcore_distro-0.2.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: graphcore-distro
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: GraphCore distro — CLI, scaffolding, and curated built-in apps
|
|
5
5
|
Author: GraphCore
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -14,9 +14,10 @@ Requires-Python: >=3.13
|
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
16
|
License-File: NOTICE
|
|
17
|
-
Requires-Dist: graphcore-kernel[redis,server]==0.2.
|
|
18
|
-
Requires-Dist: graphcore-agents==0.2.
|
|
17
|
+
Requires-Dist: graphcore-kernel[redis,server]==0.2.5
|
|
18
|
+
Requires-Dist: graphcore-agents==0.2.5
|
|
19
19
|
Requires-Dist: python-dotenv<2,>=1.0
|
|
20
|
+
Requires-Dist: packaging>=24
|
|
20
21
|
Dynamic: license-file
|
|
21
22
|
|
|
22
23
|
# graphcore-distro (distro backend)
|
|
@@ -67,9 +67,19 @@ TOPICS: dict[str, Doc] = {
|
|
|
67
67
|
"service_accounts.md",
|
|
68
68
|
"Service accounts: a process an app ships, signing in with its own client",
|
|
69
69
|
),
|
|
70
|
+
"manifests": Doc(
|
|
71
|
+
"graphcore_user_guides",
|
|
72
|
+
"manifests.md",
|
|
73
|
+
"Manifests: keyed entities an app declares and every migrate applies",
|
|
74
|
+
),
|
|
70
75
|
"production": Doc(
|
|
71
76
|
"graphcore_user_guides",
|
|
72
77
|
"production.md",
|
|
73
78
|
"Running in production: what a project needs, settings, deploy steps",
|
|
74
79
|
),
|
|
80
|
+
"upgrading": Doc(
|
|
81
|
+
"graphcore_user_guides",
|
|
82
|
+
"upgrading.md",
|
|
83
|
+
"Upgrading a project: taking a release, the template baseline, adopting an existing project",
|
|
84
|
+
),
|
|
75
85
|
}
|
|
@@ -113,6 +113,7 @@ def cmd_docker(args: argparse.Namespace) -> int:
|
|
|
113
113
|
"policy": docker_cmd.docker_policy,
|
|
114
114
|
"status": docker_cmd.docker_status,
|
|
115
115
|
"migrate": docker_cmd.docker_migrate,
|
|
116
|
+
"manifest": docker_cmd.docker_manifest,
|
|
116
117
|
}
|
|
117
118
|
return handlers[args.docker_command](args)
|
|
118
119
|
|
|
@@ -137,6 +138,13 @@ def cmd_identity(args: argparse.Namespace) -> int:
|
|
|
137
138
|
return handlers[args.identity_command](args)
|
|
138
139
|
|
|
139
140
|
|
|
141
|
+
def cmd_manifest(args: argparse.Namespace) -> int:
|
|
142
|
+
from . import manifest_cmd
|
|
143
|
+
|
|
144
|
+
handlers = {"apply": manifest_cmd.manifest_apply}
|
|
145
|
+
return handlers[args.manifest_command](args)
|
|
146
|
+
|
|
147
|
+
|
|
140
148
|
def cmd_db(args: argparse.Namespace) -> int:
|
|
141
149
|
from . import db_cmd
|
|
142
150
|
|
|
@@ -293,6 +301,13 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
293
301
|
)
|
|
294
302
|
dmigrate.set_defaults(func=cmd_docker)
|
|
295
303
|
|
|
304
|
+
dmanifest = docker_sub.add_parser(
|
|
305
|
+
"manifest", help="`graphcore manifest` via the `migrate` compose profile")
|
|
306
|
+
dmanifest_sub = dmanifest.add_subparsers(dest="manifest_command", required=True)
|
|
307
|
+
dmanifest_apply = dmanifest_sub.add_parser(
|
|
308
|
+
"apply", help="One-shot `graphcore manifest apply` in a throwaway container")
|
|
309
|
+
dmanifest_apply.set_defaults(func=cmd_docker)
|
|
310
|
+
|
|
296
311
|
infra = subparsers.add_parser(
|
|
297
312
|
"infra",
|
|
298
313
|
help="Shared local Postgres + Redis used by all deployments on this machine",
|
|
@@ -330,6 +345,13 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
330
345
|
"--secrets", action="store_true", help="Print only the variables of the client secrets the realm needs")
|
|
331
346
|
identity_render.set_defaults(func=cmd_identity)
|
|
332
347
|
|
|
348
|
+
manifest = subparsers.add_parser(
|
|
349
|
+
"manifest", help="The manifests the installed apps declare: keyed entities applied on every migrate")
|
|
350
|
+
manifest_sub = manifest.add_subparsers(dest="manifest_command", required=True)
|
|
351
|
+
manifest_apply = manifest_sub.add_parser(
|
|
352
|
+
"apply", help="Apply every declared manifest to this deployment without migrating; idempotent")
|
|
353
|
+
manifest_apply.set_defaults(func=cmd_manifest)
|
|
354
|
+
|
|
333
355
|
db = subparsers.add_parser("db", help="Postgres backup and restore for a deployment")
|
|
334
356
|
db_sub = db.add_subparsers(dest="db_command", required=True)
|
|
335
357
|
|
|
@@ -392,6 +414,14 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
392
414
|
|
|
393
415
|
skills_cmd.add_arguments(skills)
|
|
394
416
|
|
|
417
|
+
upgrade = subparsers.add_parser(
|
|
418
|
+
"upgrade",
|
|
419
|
+
help="The template baseline of a project or app: record one (--adopt), or compare it with the installed version",
|
|
420
|
+
)
|
|
421
|
+
from . import upgrade_cmd
|
|
422
|
+
|
|
423
|
+
upgrade_cmd.add_arguments(upgrade)
|
|
424
|
+
|
|
395
425
|
args = parser.parse_args(argv)
|
|
396
426
|
return args.func(args) or 0
|
|
397
427
|
|
|
@@ -17,6 +17,7 @@ from urllib.parse import quote
|
|
|
17
17
|
|
|
18
18
|
import jwt
|
|
19
19
|
|
|
20
|
+
from graphcore_cli.baseline import STATE_DIR, local_state_dir
|
|
20
21
|
from graphcore_cli.infra_cmd import infra_base_url
|
|
21
22
|
from graphcore_project import dotenv_port, find_project_root
|
|
22
23
|
from graphcore_project.http import form as _form
|
|
@@ -51,7 +52,7 @@ def _resolve_base_url(explicit: str | None) -> str:
|
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
def _resolve_session_file(explicit: str | None) -> str:
|
|
54
|
-
"""--session-file > cwd deployment's .graphcore/session.json > ~/.graphcore_session.json.
|
|
55
|
+
"""--session-file > cwd deployment's .graphcore/local/session.json > ~/.graphcore_session.json.
|
|
55
56
|
|
|
56
57
|
Per-deployment by default so two backends on one machine keep separate
|
|
57
58
|
logins instead of clobbering a single global session file.
|
|
@@ -60,10 +61,20 @@ def _resolve_session_file(explicit: str | None) -> str:
|
|
|
60
61
|
return explicit
|
|
61
62
|
root = find_project_root()
|
|
62
63
|
if root is not None:
|
|
63
|
-
return str(root
|
|
64
|
+
return str(_deployment_session_file(root))
|
|
64
65
|
return str(DEFAULT_SESSION_PATH)
|
|
65
66
|
|
|
66
67
|
|
|
68
|
+
def _deployment_session_file(root: Path) -> Path:
|
|
69
|
+
"""Where `root` keeps its session, moving there one an older CLI left in `.graphcore/`."""
|
|
70
|
+
session = local_state_dir(root) / "session.json"
|
|
71
|
+
legacy = root / STATE_DIR / "session.json"
|
|
72
|
+
if legacy.is_file() and not session.exists():
|
|
73
|
+
session.parent.mkdir(parents=True, exist_ok=True)
|
|
74
|
+
legacy.rename(session)
|
|
75
|
+
return session
|
|
76
|
+
|
|
77
|
+
|
|
67
78
|
def _with_resolved_context(fn):
|
|
68
79
|
"""Resolve args.base_url and args.session_file once before dispatching."""
|
|
69
80
|
|
|
@@ -428,7 +439,7 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
|
|
|
428
439
|
parser.add_argument(
|
|
429
440
|
"--session-file",
|
|
430
441
|
default=None,
|
|
431
|
-
help="Defaults to <deployment>/.graphcore/session.json, else ~/.graphcore_session.json.",
|
|
442
|
+
help="Defaults to <deployment>/.graphcore/local/session.json, else ~/.graphcore_session.json.",
|
|
432
443
|
)
|
|
433
444
|
|
|
434
445
|
subparsers = parser.add_subparsers(dest="api_command", required=True)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""The template baseline: what the CLI generated a project or an app from.
|
|
2
|
+
|
|
3
|
+
``.graphcore/template.json`` is committed. It holds the framework version, the
|
|
4
|
+
answers, and every template file as the CLI wrote it, so ``graphcore upgrade``
|
|
5
|
+
can tell a project's own edits from the template's. It never holds a project's
|
|
6
|
+
own file contents. Machine-local state (the CLI session) lives beside it in
|
|
7
|
+
``.graphcore/local/``, which is not committed.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
from dataclasses import dataclass
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
FORMAT = 1
|
|
17
|
+
STATE_DIR = ".graphcore"
|
|
18
|
+
BASELINE_NAME = "template.json"
|
|
19
|
+
LOCAL_NAME = "local"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class Baseline:
|
|
24
|
+
kind: str # "project", or "app" for an app generated outside a project
|
|
25
|
+
framework_version: str
|
|
26
|
+
answers: dict
|
|
27
|
+
files: dict[str, str]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def baseline_path(root: Path) -> Path:
|
|
31
|
+
return root / STATE_DIR / BASELINE_NAME
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def local_state_dir(root: Path) -> Path:
|
|
35
|
+
return root / STATE_DIR / LOCAL_NAME
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def find_root(start: Path | None = None) -> Path | None:
|
|
39
|
+
"""The nearest directory at or above `start` (default cwd) that has a baseline."""
|
|
40
|
+
current = (start or Path.cwd()).resolve()
|
|
41
|
+
for candidate in (current, *current.parents):
|
|
42
|
+
if baseline_path(candidate).is_file():
|
|
43
|
+
return candidate
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def load(root: Path) -> Baseline | None:
|
|
48
|
+
path = baseline_path(root)
|
|
49
|
+
if not path.is_file():
|
|
50
|
+
return None
|
|
51
|
+
data = json.loads(path.read_text(encoding="utf-8"))
|
|
52
|
+
if data.get("format") != FORMAT:
|
|
53
|
+
raise SystemExit(
|
|
54
|
+
f"{path} has format {data.get('format')!r}; this graphcore reads format {FORMAT}. "
|
|
55
|
+
f"Install the graphcore-distro version the project uses."
|
|
56
|
+
)
|
|
57
|
+
return Baseline(data["kind"], data["framework_version"], data["answers"], data["files"])
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def save(root: Path, baseline: Baseline) -> None:
|
|
61
|
+
path = baseline_path(root)
|
|
62
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
63
|
+
data = {
|
|
64
|
+
"format": FORMAT,
|
|
65
|
+
"kind": baseline.kind,
|
|
66
|
+
"framework_version": baseline.framework_version,
|
|
67
|
+
"answers": baseline.answers,
|
|
68
|
+
"files": dict(sorted(baseline.files.items())),
|
|
69
|
+
}
|
|
70
|
+
path.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
@@ -165,6 +165,23 @@ def docker_migrate(args) -> int:
|
|
|
165
165
|
return 1
|
|
166
166
|
|
|
167
167
|
|
|
168
|
+
def docker_manifest(args) -> int:
|
|
169
|
+
"""`graphcore docker manifest apply`: one-shot `graphcore manifest apply`
|
|
170
|
+
in a throwaway container, via the `migrate` compose service."""
|
|
171
|
+
root = require_project_root(command="graphcore docker", extra=("docker-compose.yml",))
|
|
172
|
+
env = _postgres_env(root, os.environ.copy())
|
|
173
|
+
_preflight([("Postgres", env["BACKEND_POSTGRES_HOST"], int(env["BACKEND_POSTGRES_PORT"]))])
|
|
174
|
+
|
|
175
|
+
cmd = _compose_cmd(root, "run", "--rm", "migrate", "graphcore", "manifest", "apply", profiles=[], env=env)
|
|
176
|
+
print("Running:", " ".join(cmd))
|
|
177
|
+
|
|
178
|
+
try:
|
|
179
|
+
return subprocess.run(cmd, cwd=root, env=env, check=False).returncode
|
|
180
|
+
except FileNotFoundError:
|
|
181
|
+
print("Error: docker not found. Install Docker Desktop / docker compose.", file=sys.stderr)
|
|
182
|
+
return 1
|
|
183
|
+
|
|
184
|
+
|
|
168
185
|
def docker_down(args) -> int:
|
|
169
186
|
root = require_project_root(command="graphcore docker", extra=("docker-compose.yml",))
|
|
170
187
|
env = os.environ.copy()
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"""``graphcore frontend prepare`` / ``up`` — keep the project frontend in sync
|
|
2
2
|
and start it.
|
|
3
3
|
|
|
4
|
-
``prepare`` (from a deployment root):
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
``prepare`` (from a deployment root): writes typed strategy builders for every
|
|
5
|
+
in-project app, runs ``npm install`` at the project root so new workspace
|
|
6
|
+
members link, installs and builds each ``@graphcore/*`` package linked from a
|
|
7
|
+
local checkout, then regenerates the installed-app manifests: every app under
|
|
8
|
+
``apps/`` and every app frontend package the project has installed.
|
|
8
9
|
|
|
9
10
|
``up``: runs ``prepare``, then ``npm run <script>`` in ``react_frontend/``
|
|
10
11
|
(default ``dev``). The CLI never hardcodes Vite — change the script in
|
|
@@ -19,6 +20,7 @@ import os
|
|
|
19
20
|
import re
|
|
20
21
|
import signal
|
|
21
22
|
import subprocess
|
|
23
|
+
from dataclasses import dataclass
|
|
22
24
|
from pathlib import Path
|
|
23
25
|
from typing import Any
|
|
24
26
|
|
|
@@ -33,16 +35,38 @@ GENERATED_HEADER = (
|
|
|
33
35
|
|
|
34
36
|
GENERATED_APPS_HEADER = (
|
|
35
37
|
"// GENERATED by `graphcore startapp` / `graphcore frontend prepare`.\n"
|
|
36
|
-
"// Do not edit by hand — this list mirrors the project's apps/ directory
|
|
38
|
+
"// Do not edit by hand — this list mirrors the project's apps/ directory\n"
|
|
39
|
+
"// and the app frontend packages it has installed.\n"
|
|
37
40
|
)
|
|
38
41
|
|
|
39
42
|
GENERATED_STYLES_HEADER = (
|
|
40
43
|
"/* GENERATED by `graphcore startapp` / `graphcore frontend prepare`. */\n"
|
|
41
|
-
"/* Do not edit by hand — this list mirrors the project's apps/ directory
|
|
44
|
+
"/* Do not edit by hand — this list mirrors the project's apps/ directory */\n"
|
|
45
|
+
"/* and the app frontend packages it has installed. */\n"
|
|
42
46
|
)
|
|
43
47
|
|
|
44
48
|
MANIFEST_MARKER = "generated/installedApps"
|
|
45
49
|
|
|
50
|
+
# An app frontend's package.json names its app: `"graphcore": {"app": "<app id>"}`.
|
|
51
|
+
APP_MARKER = "graphcore"
|
|
52
|
+
# The distro package; `builtinViews` registers every app frontend it depends on.
|
|
53
|
+
DISTRO_PACKAGE = "@graphcore/react"
|
|
54
|
+
PROJECT_DEPENDENCY_FIELDS = ("dependencies", "devDependencies", "optionalDependencies")
|
|
55
|
+
PACKAGE_DEPENDENCY_FIELDS = ("dependencies", "optionalDependencies", "peerDependencies")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@dataclass(frozen=True)
|
|
59
|
+
class AppFrontend:
|
|
60
|
+
"""One app frontend for the installed-app manifests."""
|
|
61
|
+
|
|
62
|
+
app: str
|
|
63
|
+
module: str # what the generated files import it as
|
|
64
|
+
styles: bool = True
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def in_project(cls, app: str) -> "AppFrontend":
|
|
68
|
+
return cls(app, f"{app}-frontend")
|
|
69
|
+
|
|
46
70
|
|
|
47
71
|
def builder_name(strategy_name: str) -> str:
|
|
48
72
|
"""'AddNote' -> 'addNote'."""
|
|
@@ -173,9 +197,9 @@ def strategies_for_app(
|
|
|
173
197
|
return result
|
|
174
198
|
|
|
175
199
|
|
|
176
|
-
def write_installed_apps_manifest(react_frontend: Path,
|
|
177
|
-
imports = "".join(f"import * as {
|
|
178
|
-
entries = ", ".join(f"{{ app: '{
|
|
200
|
+
def write_installed_apps_manifest(react_frontend: Path, apps: list[AppFrontend]) -> None:
|
|
201
|
+
imports = "".join(f"import * as {a.app}Exports from '{a.module}';\n" for a in apps)
|
|
202
|
+
entries = ", ".join(f"{{ app: '{a.app}', exports: {a.app}Exports }}" for a in apps)
|
|
179
203
|
body = (
|
|
180
204
|
f"{GENERATED_APPS_HEADER}\n{imports}\n"
|
|
181
205
|
f"export const installedApps = [{entries}];\n"
|
|
@@ -186,8 +210,8 @@ def write_installed_apps_manifest(react_frontend: Path, app_names: list[str]) ->
|
|
|
186
210
|
path.write_text(body)
|
|
187
211
|
|
|
188
212
|
|
|
189
|
-
def write_installed_styles_manifest(react_frontend: Path,
|
|
190
|
-
imports = "".join(f"@import '{
|
|
213
|
+
def write_installed_styles_manifest(react_frontend: Path, apps: list[AppFrontend]) -> None:
|
|
214
|
+
imports = "".join(f"@import '{a.module}/style.css';\n" for a in apps if a.styles)
|
|
191
215
|
body = f"{GENERATED_STYLES_HEADER}\n{imports}"
|
|
192
216
|
|
|
193
217
|
path = react_frontend / "src" / "generated" / "installedApps.css"
|
|
@@ -206,14 +230,103 @@ def app_names_with_frontend(root: Path) -> list[str]:
|
|
|
206
230
|
)
|
|
207
231
|
|
|
208
232
|
|
|
233
|
+
def read_package(directory: Path) -> dict | None:
|
|
234
|
+
try:
|
|
235
|
+
manifest = json.loads((directory / "package.json").read_text())
|
|
236
|
+
except (OSError, ValueError):
|
|
237
|
+
return None
|
|
238
|
+
return manifest if isinstance(manifest, dict) else None
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def app_id(manifest: dict) -> str | None:
|
|
242
|
+
marker = manifest.get(APP_MARKER)
|
|
243
|
+
app = marker.get("app") if isinstance(marker, dict) else None
|
|
244
|
+
return app if isinstance(app, str) and app.isidentifier() else None
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def _resolve_package(name: str, start: Path) -> Path | None:
|
|
248
|
+
"""Where Node finds package `name` from `start`: the nearest `node_modules/<name>` up the tree."""
|
|
249
|
+
for directory in (start, *start.parents):
|
|
250
|
+
candidate = directory / "node_modules" / name
|
|
251
|
+
if (candidate / "package.json").is_file():
|
|
252
|
+
return candidate
|
|
253
|
+
return None
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def _dependency_names(manifest: dict, fields: tuple[str, ...]) -> list[str]:
|
|
257
|
+
return [name for field in fields for name in (manifest.get(field) or {})]
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _has_styles(directory: Path, manifest: dict) -> bool:
|
|
261
|
+
exports = manifest.get("exports")
|
|
262
|
+
return (isinstance(exports, dict) and "./style.css" in exports) or (directory / "style.css").is_file()
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def installed_app_frontends(root: Path) -> list[AppFrontend]:
|
|
266
|
+
"""App frontend packages the project has installed, sorted by app id.
|
|
267
|
+
|
|
268
|
+
Found from the project's own dependencies, and its in-project apps', then from
|
|
269
|
+
each app frontend's dependencies in turn, so an app installed only because
|
|
270
|
+
another app depends on it is found too. In-project apps and the apps the
|
|
271
|
+
distro registers through `builtinViews` are left out.
|
|
272
|
+
"""
|
|
273
|
+
react_frontend = root / "react_frontend"
|
|
274
|
+
in_project = set(app_names_with_frontend(root))
|
|
275
|
+
pending: list[tuple[str, Path]] = []
|
|
276
|
+
for directory in [root, react_frontend, *(root / "apps" / app / "react_frontend" for app in sorted(in_project))]:
|
|
277
|
+
manifest = read_package(directory)
|
|
278
|
+
if manifest is not None:
|
|
279
|
+
pending += [(name, directory) for name in _dependency_names(manifest, PROJECT_DEPENDENCY_FIELDS)]
|
|
280
|
+
|
|
281
|
+
found: dict[str, AppFrontend] = {}
|
|
282
|
+
builtin: set[str] = set()
|
|
283
|
+
seen: set[Path] = set()
|
|
284
|
+
while pending:
|
|
285
|
+
name, start = pending.pop(0)
|
|
286
|
+
located = _resolve_package(name, start)
|
|
287
|
+
if located is None or located.resolve() in seen:
|
|
288
|
+
continue
|
|
289
|
+
directory = located.resolve()
|
|
290
|
+
seen.add(directory)
|
|
291
|
+
manifest = read_package(directory) or {}
|
|
292
|
+
if name == DISTRO_PACKAGE:
|
|
293
|
+
for dependency in _dependency_names(manifest, PACKAGE_DEPENDENCY_FIELDS):
|
|
294
|
+
package = _resolve_package(dependency, directory)
|
|
295
|
+
app = app_id(read_package(package) or {}) if package else None
|
|
296
|
+
if app:
|
|
297
|
+
builtin.add(app)
|
|
298
|
+
continue
|
|
299
|
+
app = app_id(manifest)
|
|
300
|
+
if app is None or app in in_project:
|
|
301
|
+
continue
|
|
302
|
+
if app in found and found[app].module != name:
|
|
303
|
+
raise SystemExit(f"{found[app].module} and {name} are both the frontend of app '{app}'")
|
|
304
|
+
found[app] = AppFrontend(app, name, _has_styles(directory, manifest))
|
|
305
|
+
pending += [(dependency, directory) for dependency in _dependency_names(manifest, PACKAGE_DEPENDENCY_FIELDS)]
|
|
306
|
+
|
|
307
|
+
apps = []
|
|
308
|
+
for app in sorted(found.keys() - builtin):
|
|
309
|
+
frontend = found[app]
|
|
310
|
+
if _resolve_package(frontend.module, react_frontend) is None:
|
|
311
|
+
print(
|
|
312
|
+
f"Skipping app '{app}': {frontend.module} is installed, but not where react_frontend/ can "
|
|
313
|
+
f"import it. Add it to react_frontend/package.json.",
|
|
314
|
+
flush=True,
|
|
315
|
+
)
|
|
316
|
+
continue
|
|
317
|
+
apps.append(frontend)
|
|
318
|
+
return apps
|
|
319
|
+
|
|
320
|
+
|
|
209
321
|
def sync_installed_apps(root: Path) -> list[str]:
|
|
210
|
-
"""Regenerate installed-app manifests
|
|
211
|
-
the app
|
|
212
|
-
|
|
322
|
+
"""Regenerate the installed-app manifests: apps/*/react_frontend, then the
|
|
323
|
+
installed app frontend packages. Returns the app ids that were synced."""
|
|
324
|
+
apps = [AppFrontend.in_project(name) for name in app_names_with_frontend(root)]
|
|
325
|
+
apps += installed_app_frontends(root)
|
|
213
326
|
react_frontend = root / "react_frontend"
|
|
214
|
-
write_installed_apps_manifest(react_frontend,
|
|
215
|
-
write_installed_styles_manifest(react_frontend,
|
|
216
|
-
return
|
|
327
|
+
write_installed_apps_manifest(react_frontend, apps)
|
|
328
|
+
write_installed_styles_manifest(react_frontend, apps)
|
|
329
|
+
return [a.app for a in apps]
|
|
217
330
|
|
|
218
331
|
|
|
219
332
|
def write_strategies_module(root: Path, app_name: str, strategies: list[dict]) -> Path:
|
|
@@ -384,9 +497,8 @@ def stop_watch_builds(processes: list[subprocess.Popen]) -> None:
|
|
|
384
497
|
|
|
385
498
|
|
|
386
499
|
def prepare_frontend(root: Path, *, install: bool = True, codegen: bool = True) -> list[str]:
|
|
387
|
-
"""
|
|
388
|
-
Returns the synced app
|
|
389
|
-
app_names = sync_installed_apps(root)
|
|
500
|
+
"""Optionally codegen all apps, optionally npm install, then sync the manifests
|
|
501
|
+
from what is installed. Returns the synced app ids."""
|
|
390
502
|
if codegen:
|
|
391
503
|
codegen_all_apps(root)
|
|
392
504
|
if install:
|
|
@@ -395,7 +507,7 @@ def prepare_frontend(root: Path, *, install: bool = True, codegen: bool = True)
|
|
|
395
507
|
raise SystemExit(f"npm install failed (exit {code})")
|
|
396
508
|
install_linked_dependencies(root)
|
|
397
509
|
build_linked_packages(root)
|
|
398
|
-
return
|
|
510
|
+
return sync_installed_apps(root)
|
|
399
511
|
|
|
400
512
|
|
|
401
513
|
def prepare(args: argparse.Namespace) -> int:
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""``graphcore manifest apply``: the manifests the installed apps declare."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from graphcore_project import apply_manifests, require_project_root
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def manifest_apply(args) -> int:
|
|
9
|
+
return apply_manifests(require_project_root(command="graphcore manifest apply"))
|