graphcore-kernel 0.1.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.
- graphcore/__init__.py +5 -0
- graphcore/agent_frontend/__init__.py +8 -0
- graphcore/agent_frontend/api.py +69 -0
- graphcore/agent_frontend/base/__init__.py +11 -0
- graphcore/agent_frontend/base/views.py +167 -0
- graphcore/agent_frontend/client.py +31 -0
- graphcore/agent_frontend/context.py +157 -0
- graphcore/agent_frontend/errors.py +12 -0
- graphcore/agent_frontend/loading.py +54 -0
- graphcore/agent_frontend/registry.py +42 -0
- graphcore/agent_frontend/render.py +207 -0
- graphcore/agent_frontend/server.py +103 -0
- graphcore/agent_frontend/signatures.py +35 -0
- graphcore/agent_frontend/testing.py +45 -0
- graphcore/agent_frontend/tests/__init__.py +0 -0
- graphcore/agent_frontend/tests/fakes.py +114 -0
- graphcore/agent_frontend/tests/test_frontend.py +447 -0
- graphcore/agent_frontend/tests/test_loading.py +83 -0
- graphcore/agent_frontend/tests/test_server.py +109 -0
- graphcore/agent_frontend/tools.py +137 -0
- graphcore/api/__init__.py +4 -0
- graphcore/api/graph_api.py +378 -0
- graphcore/api/predicate_codec.py +81 -0
- graphcore/api/tests/__init__.py +0 -0
- graphcore/api/tests/test_changed_entities.py +109 -0
- graphcore/api/tests/test_graph_api.py +290 -0
- graphcore/api/tests/test_graph_api_access.py +94 -0
- graphcore/api/tests/test_graph_api_grants.py +90 -0
- graphcore/api/tests/test_predicate_codec.py +83 -0
- graphcore/api/tests/test_subtree_query.py +79 -0
- graphcore/apps.py +71 -0
- graphcore/auth/__init__.py +1 -0
- graphcore/auth/authn/README.md +178 -0
- graphcore/auth/authn/__init__.py +3 -0
- graphcore/auth/authn/authenticator.py +120 -0
- graphcore/auth/authn/onboarding.py +105 -0
- graphcore/auth/authn/principals.py +20 -0
- graphcore/auth/authn/resource_metadata.py +43 -0
- graphcore/auth/authn/service_accounts.py +96 -0
- graphcore/auth/authn/testing.py +96 -0
- graphcore/auth/authn/tests/__init__.py +0 -0
- graphcore/auth/authn/tests/test_authenticator.py +145 -0
- graphcore/auth/authn/tests/test_onboarding.py +145 -0
- graphcore/auth/authn/tests/test_service_accounts.py +180 -0
- graphcore/auth/authn/users.py +59 -0
- graphcore/auth/authz/__init__.py +0 -0
- graphcore/auth/authz/access_port.py +120 -0
- graphcore/auth/authz/adapter/__init__.py +0 -0
- graphcore/auth/authz/adapter/default_access_adapter.py +556 -0
- graphcore/auth/authz/adapter/tests/__init__.py +0 -0
- graphcore/auth/authz/adapter/tests/test_default_adapter.py +543 -0
- graphcore/auth/authz/adapter/tests/test_entity_write_hooks.py +207 -0
- graphcore/auth/authz/adapter/tests/test_group_types.py +70 -0
- graphcore/auth/authz/adapter/tests/test_sync_support.py +209 -0
- graphcore/auth/authz/defaults.py +26 -0
- graphcore/auth/authz/kernel_policy.py +191 -0
- graphcore/auth/authz/kernel_writes.py +31 -0
- graphcore/auth/authz/lookups.py +25 -0
- graphcore/auth/authz/policy.py +403 -0
- graphcore/auth/authz/tests/__init__.py +0 -0
- graphcore/auth/authz/tests/test_can_contain.py +150 -0
- graphcore/auth/authz/tests/test_contained_by.py +167 -0
- graphcore/auth/authz/tests/test_creation.py +391 -0
- graphcore/auth/authz/tests/test_delete_permission.py +82 -0
- graphcore/auth/authz/tests/test_granted_to_me.py +160 -0
- graphcore/auth/authz/tests/test_integration.py +637 -0
- graphcore/auth/authz/tests/test_invites.py +184 -0
- graphcore/auth/authz/tests/test_kernel_policy.py +140 -0
- graphcore/auth/authz/tests/test_lockout.py +132 -0
- graphcore/auth/authz/tests/test_policy.py +329 -0
- graphcore/auth/authz/tests/test_primitives.py +73 -0
- graphcore/auth/authz/tests/test_principal_creation.py +62 -0
- graphcore/bootstrap/__init__.py +0 -0
- graphcore/bootstrap/deployment.py +67 -0
- graphcore/bootstrap/signals.py +16 -0
- graphcore/bootstrap/tests/__init__.py +0 -0
- graphcore/bootstrap/tests/test_deployment_seed.py +154 -0
- graphcore/broadcast/__init__.py +4 -0
- graphcore/broadcast/broadcaster.py +201 -0
- graphcore/broadcast/channels.py +56 -0
- graphcore/broadcast/tests/__init__.py +0 -0
- graphcore/broadcast/tests/test_broadcaster.py +444 -0
- graphcore/celery.py +14 -0
- graphcore/docs/AGENT_FRONTEND_TDD.md +389 -0
- graphcore/docs/ARCHITECTURE_PRINCIPLES.md +152 -0
- graphcore/docs/AUTHORIZATION_TECHNICAL_TDD.md +1379 -0
- graphcore/docs/ENTITY_REFERENCE_TDD.md +561 -0
- graphcore/docs/GRAPHAPI_FRONT_DOOR.md +173 -0
- graphcore/docs/RUNTIME.md +90 -0
- graphcore/docs/SCHEDULING_TDD.md +244 -0
- graphcore/docs/STRATEGY_EXECUTION_TDD.md +1043 -0
- graphcore/docs/VIEW_ENTITY_TDD.md +522 -0
- graphcore/docs/VIEW_SYSTEM_TDD.md +307 -0
- graphcore/docs/__init__.py +0 -0
- graphcore/docs/doc_topics.py +97 -0
- graphcore/docs/docs_discovery.py +64 -0
- graphcore/docs/public_api.py +56 -0
- graphcore/domain/__init__.py +0 -0
- graphcore/domain/entity/Entity.py +204 -0
- graphcore/domain/entity/__init__.py +0 -0
- graphcore/domain/entity/deployment/Deployment.py +25 -0
- graphcore/domain/entity/deployment/__init__.py +0 -0
- graphcore/domain/entity/grant/Grant.py +31 -0
- graphcore/domain/entity/grant/__init__.py +0 -0
- graphcore/domain/entity/group/Group.py +48 -0
- graphcore/domain/entity/group/README.md +88 -0
- graphcore/domain/entity/group/__init__.py +0 -0
- graphcore/domain/entity/invite/Invite.py +31 -0
- graphcore/domain/entity/invite/__init__.py +0 -0
- graphcore/domain/entity/request_template/RequestTemplate.py +48 -0
- graphcore/domain/entity/request_template/__init__.py +0 -0
- graphcore/domain/entity/request_template/tests/__init__.py +0 -0
- graphcore/domain/entity/request_template/tests/test_request_template.py +52 -0
- graphcore/domain/entity/service_account/ServiceAccount.py +41 -0
- graphcore/domain/entity/service_account/__init__.py +0 -0
- graphcore/domain/entity/strategy_request/StrategyRequest.py +61 -0
- graphcore/domain/entity/strategy_request/__init__.py +0 -0
- graphcore/domain/entity/strategy_request/tests/__init__.py +0 -0
- graphcore/domain/entity/strategy_request/tests/test_strategy_request_entity.py +35 -0
- graphcore/domain/entity/tests/__init__.py +0 -0
- graphcore/domain/entity/tests/test_entity.py +227 -0
- graphcore/domain/entity/tests/test_grant_group_entities.py +36 -0
- graphcore/domain/entity/tests/test_write_once_fields.py +98 -0
- graphcore/domain/entity/user/User.py +39 -0
- graphcore/domain/entity/user/__init__.py +0 -0
- graphcore/domain/entity/user/tests/__init__.py +0 -0
- graphcore/domain/entity/user/tests/test_user_entity.py +33 -0
- graphcore/domain/entity/view/View.py +37 -0
- graphcore/domain/entity/view/__init__.py +0 -0
- graphcore/domain/entity/view/position.py +78 -0
- graphcore/domain/entity/view/tests/__init__.py +0 -0
- graphcore/domain/entity/view/tests/test_position.py +71 -0
- graphcore/domain/entity/view/tests/test_view_entity.py +134 -0
- graphcore/domain/strategy/BaseStrategy.py +759 -0
- graphcore/domain/strategy/DeploymentStrategies.py +55 -0
- graphcore/domain/strategy/GrantStrategies.py +189 -0
- graphcore/domain/strategy/GroupStrategies.py +193 -0
- graphcore/domain/strategy/InviteStrategies.py +84 -0
- graphcore/domain/strategy/RequestTemplateStrategies.py +126 -0
- graphcore/domain/strategy/ViewStrategies.py +219 -0
- graphcore/domain/strategy/__init__.py +0 -0
- graphcore/domain/strategy/runner.py +84 -0
- graphcore/domain/strategy/session.py +56 -0
- graphcore/domain/strategy/tests/BaseStrategyTest.py +167 -0
- graphcore/domain/strategy/tests/__init__.py +0 -0
- graphcore/domain/strategy/tests/test_BaseStrategies.py +870 -0
- graphcore/domain/strategy/tests/test_grant_strategies.py +245 -0
- graphcore/domain/strategy/tests/test_group_strategies.py +99 -0
- graphcore/domain/strategy/tests/test_runner.py +220 -0
- graphcore/domain/strategy/tests/test_strategy_locks.py +446 -0
- graphcore/domain/strategy/tests/test_utils.py +95 -0
- graphcore/domain/strategy/tests/test_view_strategies.py +436 -0
- graphcore/errors.py +145 -0
- graphcore/execution/README.md +97 -0
- graphcore/execution/StrategyExecutorService.py +333 -0
- graphcore/execution/__init__.py +0 -0
- graphcore/execution/dispatcher.py +19 -0
- graphcore/execution/environments/__init__.py +0 -0
- graphcore/execution/environments/celery.py +59 -0
- graphcore/execution/environments/in_process.py +55 -0
- graphcore/execution/local_session.py +117 -0
- graphcore/execution/redis_run_events.py +74 -0
- graphcore/execution/requests.py +22 -0
- graphcore/execution/run_events.py +85 -0
- graphcore/execution/strategy_context.py +54 -0
- graphcore/execution/tasks.py +34 -0
- graphcore/execution/tests/__init__.py +5 -0
- graphcore/execution/tests/contract.py +171 -0
- graphcore/execution/tests/support.py +310 -0
- graphcore/execution/tests/test_dispatchers.py +76 -0
- graphcore/execution/tests/test_executor.py +368 -0
- graphcore/execution/tests/test_local_session.py +95 -0
- graphcore/execution/tests/test_reconcile_runs.py +134 -0
- graphcore/execution/tests/test_run_events.py +106 -0
- graphcore/execution/tests/test_strategy_context.py +62 -0
- graphcore/gateway/__init__.py +1 -0
- graphcore/gateway/remote.py +35 -0
- graphcore/gateway/tests/__init__.py +0 -0
- graphcore/gateway/tests/test_remote.py +30 -0
- graphcore/graph/EntityService.py +710 -0
- graphcore/graph/__init__.py +0 -0
- graphcore/graph/entity_cache.py +152 -0
- graphcore/graph/tests/__init__.py +4 -0
- graphcore/graph/tests/test_EntityService.py +908 -0
- graphcore/graph/tests/test_EntityService_list.py +170 -0
- graphcore/graph/tests/test_EntityService_model_resolution.py +339 -0
- graphcore/graph/tests/test_EntityService_referrers.py +236 -0
- graphcore/graph/tests/test_EntityService_routing.py +119 -0
- graphcore/graph/tests/test_dependent_on.py +141 -0
- graphcore/graph/tests/test_engine_is_type_agnostic.py +25 -0
- graphcore/graph/tests/test_engine_resolves_read_permission.py +93 -0
- graphcore/graph/tests/test_entity_cache.py +159 -0
- graphcore/graph/tests/test_null_entity_cache.py +12 -0
- graphcore/management/__init__.py +0 -0
- graphcore/management/commands/__init__.py +0 -0
- graphcore/management/commands/dev_reset.py +18 -0
- graphcore/management/commands/graphcore_createadmin.py +65 -0
- graphcore/management/commands/graphcore_policy.py +59 -0
- graphcore/management/commands/graphcore_status.py +98 -0
- graphcore/management/tests/__init__.py +0 -0
- graphcore/management/tests/test_createadmin.py +78 -0
- graphcore/management/tests/test_policy_command.py +46 -0
- graphcore/management/tests/test_status_command.py +85 -0
- graphcore/migrations/0001_initial.py +186 -0
- graphcore/migrations/0002_invite.py +26 -0
- graphcore/migrations/__init__.py +0 -0
- graphcore/models.py +11 -0
- graphcore/persistence/ENTITY_REPOSITORY_TECHNICAL_TDD.md +396 -0
- graphcore/persistence/__init__.py +6 -0
- graphcore/persistence/django/__init__.py +0 -0
- graphcore/persistence/django/backends.py +43 -0
- graphcore/persistence/django/bindings.py +28 -0
- graphcore/persistence/django/cache.py +38 -0
- graphcore/persistence/django/compiler.py +214 -0
- graphcore/persistence/django/identity.py +18 -0
- graphcore/persistence/django/models.py +252 -0
- graphcore/persistence/django/repository.py +525 -0
- graphcore/persistence/django/tests/__init__.py +0 -0
- graphcore/persistence/django/tests/test_backends.py +68 -0
- graphcore/persistence/django/tests/test_compiler.py +269 -0
- graphcore/persistence/django/tests/test_repository.py +472 -0
- graphcore/persistence/django/tests/test_shared_column.py +120 -0
- graphcore/persistence/django/tests/test_threads.py +50 -0
- graphcore/persistence/django/tests/test_update_shape.py +175 -0
- graphcore/persistence/django/threads.py +38 -0
- graphcore/persistence/repository.py +172 -0
- graphcore/persistence/tests/__init__.py +0 -0
- graphcore/persistence/tests/contract.py +688 -0
- graphcore/persistence/tests/evaluate.py +51 -0
- graphcore/persistence/tests/fixtures.py +32 -0
- graphcore/persistence/tests/memory.py +263 -0
- graphcore/persistence/tests/test_memory_repository.py +10 -0
- graphcore/persistence/tests/test_query_types.py +127 -0
- graphcore/public/__init__.py +9 -0
- graphcore/public/api.py +9 -0
- graphcore/public/apps.py +10 -0
- graphcore/public/auth/__init__.py +1 -0
- graphcore/public/auth/grants.py +7 -0
- graphcore/public/auth/onboarding.py +8 -0
- graphcore/public/auth/perms.py +7 -0
- graphcore/public/auth/policy.py +10 -0
- graphcore/public/auth/roles.py +8 -0
- graphcore/public/auth/subjects.py +7 -0
- graphcore/public/entities/__init__.py +32 -0
- graphcore/public/errors.py +19 -0
- graphcore/public/persistence/__init__.py +44 -0
- graphcore/public/persistence/django.py +24 -0
- graphcore/public/scheduling.py +23 -0
- graphcore/public/strategies/__init__.py +85 -0
- graphcore/public/test_settings.py +16 -0
- graphcore/public/testing.py +47 -0
- graphcore/registry/EntityDirectory.py +246 -0
- graphcore/registry/README.md +147 -0
- graphcore/registry/StrategyDirectory.py +308 -0
- graphcore/registry/TYPE_METADATA_PLACEMENT.md +66 -0
- graphcore/registry/__init__.py +0 -0
- graphcore/registry/app_discovery.py +108 -0
- graphcore/registry/decorators.py +77 -0
- graphcore/registry/discovery.py +111 -0
- graphcore/registry/registry.py +79 -0
- graphcore/registry/tests/__init__.py +0 -0
- graphcore/registry/tests/test_agent_frontend_discovery.py +56 -0
- graphcore/registry/tests/test_app_config.py +36 -0
- graphcore/registry/tests/test_discovery.py +147 -0
- graphcore/registry/tests/test_entity_directory_storage.py +73 -0
- graphcore/registry/tests/test_import_package.py +87 -0
- graphcore/registry/tests/test_principal_flag.py +67 -0
- graphcore/registry/tests/test_strategy_directory.py +29 -0
- graphcore/routes/__init__.py +116 -0
- graphcore/routes/tests/__init__.py +0 -0
- graphcore/routes/tests/test_routes.py +90 -0
- graphcore/runtime.py +243 -0
- graphcore/scheduling/__init__.py +0 -0
- graphcore/scheduling/beat_scheduler.py +164 -0
- graphcore/scheduling/beat_tasks.py +63 -0
- graphcore/scheduling/scheduler.py +37 -0
- graphcore/scheduling/tests/__init__.py +0 -0
- graphcore/scheduling/tests/contract.py +136 -0
- graphcore/scheduling/tests/memory.py +42 -0
- graphcore/scheduling/tests/test_beat_scheduler.py +87 -0
- graphcore/scheduling/tests/test_memory_scheduler.py +15 -0
- graphcore/scheduling/tests/test_ticks.py +143 -0
- graphcore/tasks.py +9 -0
- graphcore/test_settings.py +78 -0
- graphcore/testing/__init__.py +0 -0
- graphcore/testing/case.py +112 -0
- graphcore/testing/runner.py +32 -0
- graphcore/testing/settings.py +26 -0
- graphcore/testing/tests/__init__.py +0 -0
- graphcore/testing/tests/agent_view_fixture.py +19 -0
- graphcore/testing/tests/test_case_and_runner.py +219 -0
- graphcore/testing/tests/test_settings_for_apps.py +50 -0
- graphcore/tests/__init__.py +0 -0
- graphcore/tests/ids.py +14 -0
- graphcore/tests/public_api_manifest.py +102 -0
- graphcore/tests/runs.py +7 -0
- graphcore/tests/test_app_discovery.py +90 -0
- graphcore/tests/test_composition_boundaries.py +231 -0
- graphcore/tests/test_docs_discovery.py +108 -0
- graphcore/tests/test_no_print.py +70 -0
- graphcore/tests/test_packaging.py +64 -0
- graphcore/tests/test_public_api_boundaries.py +229 -0
- graphcore/tests/test_public_api_contract.py +62 -0
- graphcore/tests/test_public_api_docs.py +28 -0
- graphcore/tests/test_runtime.py +42 -0
- graphcore/tests/test_shared_type_boundaries.py +128 -0
- graphcore/tests/test_shared_types.py +144 -0
- graphcore/tests/test_test_settings.py +45 -0
- graphcore/transport/__init__.py +0 -0
- graphcore/transport/agent_asgi.py +68 -0
- graphcore/transport/agent_client.py +85 -0
- graphcore/transport/channel_layer.py +68 -0
- graphcore/transport/consumers.py +507 -0
- graphcore/transport/routing.py +6 -0
- graphcore/transport/tests/__init__.py +0 -0
- graphcore/transport/tests/test_agent_client.py +31 -0
- graphcore/transport/tests/test_api_views.py +733 -0
- graphcore/transport/tests/test_channel_layer.py +96 -0
- graphcore/transport/tests/test_consumers.py +963 -0
- graphcore/transport/tests/test_resource_metadata.py +67 -0
- graphcore/transport/urls.py +29 -0
- graphcore/transport/views.py +358 -0
- graphcore/types/__init__.py +4 -0
- graphcore/types/access.py +114 -0
- graphcore/types/api.py +76 -0
- graphcore/types/entities.py +100 -0
- graphcore/types/entity_id.py +85 -0
- graphcore/types/execution.py +41 -0
- graphcore/types/identity.py +20 -0
- graphcore/types/onboarding.py +20 -0
- graphcore/types/query.py +116 -0
- graphcore/types/schedules.py +91 -0
- graphcore/types/strategy.py +73 -0
- graphcore/types/tests/__init__.py +0 -0
- graphcore/types/tests/test_entity_id.py +50 -0
- graphcore/urls.py +5 -0
- graphcore_kernel-0.1.0.dist-info/METADATA +94 -0
- graphcore_kernel-0.1.0.dist-info/RECORD +343 -0
- graphcore_kernel-0.1.0.dist-info/WHEEL +5 -0
- graphcore_kernel-0.1.0.dist-info/entry_points.txt +2 -0
- graphcore_kernel-0.1.0.dist-info/licenses/LICENSE +202 -0
- graphcore_kernel-0.1.0.dist-info/licenses/NOTICE +2 -0
- graphcore_kernel-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"""`graphcore.runtime` is the single composition root: only its allowed
|
|
2
|
+
entrypoints may call into it, and no other module may construct the live
|
|
3
|
+
components it wires or reach the process-wide registry directly."""
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from django.test import SimpleTestCase
|
|
7
|
+
|
|
8
|
+
import graphcore
|
|
9
|
+
from graphcore.tests.test_shared_type_boundaries import imported_modules
|
|
10
|
+
|
|
11
|
+
ROOT = Path(graphcore.__file__).resolve().parent
|
|
12
|
+
|
|
13
|
+
RUNTIME_ALLOWED_IMPORTERS = {
|
|
14
|
+
ROOT / 'runtime.py',
|
|
15
|
+
ROOT / 'transport' / 'views.py',
|
|
16
|
+
ROOT / 'transport' / 'consumers.py',
|
|
17
|
+
ROOT / 'transport' / 'agent_client.py',
|
|
18
|
+
# Celery entry points: each task resolves its process's runtime.
|
|
19
|
+
ROOT / 'execution' / 'tasks.py',
|
|
20
|
+
ROOT / 'execution' / 'environments' / 'celery.py',
|
|
21
|
+
ROOT / 'scheduling' / 'beat_tasks.py',
|
|
22
|
+
ROOT / 'auth' / 'authn' / 'authenticator.py',
|
|
23
|
+
ROOT / 'management' / 'commands' / 'dev_reset.py',
|
|
24
|
+
ROOT / 'management' / 'commands' / 'graphcore_createadmin.py',
|
|
25
|
+
ROOT / 'management' / 'commands' / 'graphcore_policy.py',
|
|
26
|
+
ROOT / 'management' / 'commands' / 'graphcore_status.py',
|
|
27
|
+
ROOT / 'bootstrap' / 'signals.py',
|
|
28
|
+
# App-author test harness: an entry point that builds a runtime per test.
|
|
29
|
+
ROOT / 'testing' / 'case.py',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
LIVE_COMPONENT_CONSTRUCTORS = (
|
|
33
|
+
'DjangoEntityRepository(', 'DjangoCache(', 'DefaultAccessAdapter(',
|
|
34
|
+
'ChannelsBroadcaster(', 'NoRemoteGateway(', 'EntityService(',
|
|
35
|
+
'StrategyExecutorService(', 'GraphAPI(', 'BeatScheduler(',
|
|
36
|
+
'InProcessDispatcher(', 'CeleryDispatcher(', 'RedisRunEvents(',
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# The defining module for each constructor above is allowed to name itself.
|
|
40
|
+
LIVE_COMPONENT_DEFINERS = {
|
|
41
|
+
ROOT / 'persistence' / 'django' / 'repository.py',
|
|
42
|
+
ROOT / 'persistence' / 'django' / 'cache.py',
|
|
43
|
+
ROOT / 'auth' / 'authz' / 'adapter' / 'default_access_adapter.py',
|
|
44
|
+
ROOT / 'broadcast' / 'channels.py',
|
|
45
|
+
ROOT / 'gateway' / 'remote.py',
|
|
46
|
+
ROOT / 'graph' / 'EntityService.py',
|
|
47
|
+
ROOT / 'execution' / 'StrategyExecutorService.py',
|
|
48
|
+
ROOT / 'api' / 'graph_api.py',
|
|
49
|
+
ROOT / 'scheduling' / 'beat_scheduler.py',
|
|
50
|
+
ROOT / 'execution' / 'environments' / 'in_process.py',
|
|
51
|
+
ROOT / 'execution' / 'environments' / 'celery.py',
|
|
52
|
+
ROOT / 'execution' / 'redis_run_events.py',
|
|
53
|
+
ROOT / 'runtime.py',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
DEFAULT_REGISTRY_ALLOWED = {
|
|
57
|
+
ROOT / 'registry' / 'registry.py',
|
|
58
|
+
ROOT / 'registry' / 'discovery.py',
|
|
59
|
+
ROOT / 'runtime.py',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
SETTINGS_ALLOWED = {
|
|
63
|
+
ROOT / 'runtime.py',
|
|
64
|
+
ROOT / 'auth' / 'authz' / 'kernel_policy.py',
|
|
65
|
+
# Authn's own deployment posture (GRAPHCORE_TRUSTED_ISSUERS) - out of
|
|
66
|
+
# scope for this composition root; not a live collaborator wired through
|
|
67
|
+
# `Runtime`.
|
|
68
|
+
ROOT / 'auth' / 'authn' / 'authenticator.py',
|
|
69
|
+
ROOT / 'auth' / 'authn' / 'resource_metadata.py',
|
|
70
|
+
# The app-author test case and runner find the project's apps from
|
|
71
|
+
# BASE_DIR and GRAPHCORE_APPS.
|
|
72
|
+
ROOT / 'testing' / 'case.py',
|
|
73
|
+
ROOT / 'testing' / 'runner.py',
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# Only `EntityService` branches on where an entity lives.
|
|
78
|
+
BACKEND_SEGMENT_READERS = {
|
|
79
|
+
ROOT / 'types' / 'entity_id.py',
|
|
80
|
+
ROOT / 'graph' / 'EntityService.py',
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
DJANGO_MODELS = 'graphcore.persistence.django.models'
|
|
84
|
+
|
|
85
|
+
# Everything else reaches storage through `EntityRepository`.
|
|
86
|
+
DJANGO_MODELS_ALLOWED_IMPORTERS = {
|
|
87
|
+
# Django model discovery for the `graphcore` app label.
|
|
88
|
+
ROOT / 'models.py',
|
|
89
|
+
ROOT / 'public' / 'persistence' / 'django.py',
|
|
90
|
+
# `BackendIdentityModel` bootstrap on post_migrate - tracked separately.
|
|
91
|
+
ROOT / 'apps.py',
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
BEAT_ADAPTER = ROOT / 'scheduling' / 'beat_scheduler.py'
|
|
96
|
+
|
|
97
|
+
# Neither names the adapter nor reaches Beat; they use the injected Scheduler.
|
|
98
|
+
SCHEDULER_CLIENTS = (
|
|
99
|
+
ROOT / 'domain' / 'strategy' / 'RequestTemplateStrategies.py',
|
|
100
|
+
ROOT / 'graph' / 'EntityService.py',
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
# Celery is one execution environment; the rest of execution names none.
|
|
104
|
+
CELERY_IMPORTERS_IN_EXECUTION = {
|
|
105
|
+
ROOT / 'execution' / 'environments' / 'celery.py',
|
|
106
|
+
ROOT / 'execution' / 'tasks.py',
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# Strategies reach the graph only through their session.
|
|
110
|
+
DOMAIN_FORBIDDEN_IMPORTS = (
|
|
111
|
+
'graphcore.graph', 'graphcore.execution', 'graphcore.persistence', 'graphcore.broadcast',
|
|
112
|
+
'graphcore.scheduling', 'graphcore.auth.authz.adapter', 'graphcore.runtime', 'graphcore.api',
|
|
113
|
+
'graphcore.transport',
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _imports_any(imports, prefixes) -> bool:
|
|
118
|
+
return any(name == prefix or name.startswith(prefix + '.') for name in imports for prefix in prefixes)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _source_files():
|
|
122
|
+
for path in ROOT.rglob('*.py'):
|
|
123
|
+
if 'tests' in path.parts or '__pycache__' in path.parts or 'migrations' in path.parts:
|
|
124
|
+
continue
|
|
125
|
+
yield path
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _package_for(path):
|
|
129
|
+
return 'graphcore.' + '.'.join(path.relative_to(ROOT).parts[:-1])
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class CompositionRootBoundaryTests(SimpleTestCase):
|
|
133
|
+
def test_only_entrypoints_import_runtime(self):
|
|
134
|
+
for path in _source_files():
|
|
135
|
+
if path in RUNTIME_ALLOWED_IMPORTERS:
|
|
136
|
+
continue
|
|
137
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
138
|
+
imports = list(imported_modules(path.read_text(), _package_for(path)))
|
|
139
|
+
self.assertNotIn('graphcore.runtime', imports)
|
|
140
|
+
self.assertFalse(any(name.startswith('graphcore.runtime.') for name in imports))
|
|
141
|
+
|
|
142
|
+
def test_only_the_composition_root_constructs_live_components(self):
|
|
143
|
+
for path in _source_files():
|
|
144
|
+
if path in LIVE_COMPONENT_DEFINERS:
|
|
145
|
+
continue
|
|
146
|
+
source = path.read_text()
|
|
147
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
148
|
+
for ctor in LIVE_COMPONENT_CONSTRUCTORS:
|
|
149
|
+
self.assertNotIn(ctor, source)
|
|
150
|
+
|
|
151
|
+
def test_only_the_entity_service_reads_the_backend_segment(self):
|
|
152
|
+
for path in _source_files():
|
|
153
|
+
if path in BACKEND_SEGMENT_READERS:
|
|
154
|
+
continue
|
|
155
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
156
|
+
self.assertNotIn('backend_of(', path.read_text())
|
|
157
|
+
|
|
158
|
+
def test_only_registry_and_discovery_reach_the_process_wide_registry(self):
|
|
159
|
+
for path in _source_files():
|
|
160
|
+
if path in DEFAULT_REGISTRY_ALLOWED:
|
|
161
|
+
continue
|
|
162
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
163
|
+
self.assertNotIn('DEFAULT_REGISTRY', path.read_text())
|
|
164
|
+
|
|
165
|
+
def test_only_the_django_store_and_its_entry_points_import_its_models(self):
|
|
166
|
+
django_store = ROOT / 'persistence' / 'django'
|
|
167
|
+
for path in _source_files():
|
|
168
|
+
if path in DJANGO_MODELS_ALLOWED_IMPORTERS or path.is_relative_to(django_store):
|
|
169
|
+
continue
|
|
170
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
171
|
+
imports = list(imported_modules(path.read_text(), _package_for(path)))
|
|
172
|
+
self.assertFalse(any(name == DJANGO_MODELS or name.startswith(DJANGO_MODELS + '.')
|
|
173
|
+
for name in imports))
|
|
174
|
+
|
|
175
|
+
def test_only_composition_and_documented_deployment_posture_read_settings(self):
|
|
176
|
+
for path in _source_files():
|
|
177
|
+
if path in SETTINGS_ALLOWED:
|
|
178
|
+
continue
|
|
179
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
180
|
+
imports = list(imported_modules(path.read_text(), _package_for(path)))
|
|
181
|
+
self.assertFalse(any(name == 'django.conf' or name == 'django.conf.settings'
|
|
182
|
+
or name.startswith('django.conf.settings.') for name in imports))
|
|
183
|
+
|
|
184
|
+
def test_only_the_beat_scheduler_imports_django_celery_beat(self):
|
|
185
|
+
for path in _source_files():
|
|
186
|
+
if path == BEAT_ADAPTER:
|
|
187
|
+
continue
|
|
188
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
189
|
+
imports = list(imported_modules(path.read_text(), _package_for(path)))
|
|
190
|
+
self.assertFalse(any(name == 'django_celery_beat' or name.startswith('django_celery_beat.')
|
|
191
|
+
for name in imports))
|
|
192
|
+
|
|
193
|
+
def test_celery_is_confined_to_its_environment(self):
|
|
194
|
+
for path in (ROOT / 'execution').rglob('*.py'):
|
|
195
|
+
if path in CELERY_IMPORTERS_IN_EXECUTION or 'tests' in path.parts or '__pycache__' in path.parts:
|
|
196
|
+
continue
|
|
197
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
198
|
+
imports = list(imported_modules(path.read_text(), _package_for(path)))
|
|
199
|
+
self.assertFalse(_imports_any(imports, ('celery', 'graphcore.execution.environments.celery')))
|
|
200
|
+
|
|
201
|
+
def test_the_domain_imports_no_kernel_service(self):
|
|
202
|
+
for path in (ROOT / 'domain').rglob('*.py'):
|
|
203
|
+
if 'tests' in path.parts or '__pycache__' in path.parts:
|
|
204
|
+
continue
|
|
205
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
206
|
+
imports = list(imported_modules(path.read_text(), _package_for(path)))
|
|
207
|
+
self.assertFalse(_imports_any(imports, DOMAIN_FORBIDDEN_IMPORTS))
|
|
208
|
+
|
|
209
|
+
def test_the_executor_has_no_scheduling_code(self):
|
|
210
|
+
for path in (ROOT / 'execution').rglob('*.py'):
|
|
211
|
+
if 'tests' in path.parts or '__pycache__' in path.parts:
|
|
212
|
+
continue
|
|
213
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
214
|
+
imports = list(imported_modules(path.read_text(), _package_for(path)))
|
|
215
|
+
self.assertFalse(_imports_any(imports, ('graphcore.scheduling', 'django_celery_beat')))
|
|
216
|
+
|
|
217
|
+
def test_scheduler_clients_use_the_injected_port(self):
|
|
218
|
+
for path in SCHEDULER_CLIENTS:
|
|
219
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
220
|
+
imports = list(imported_modules(path.read_text(), _package_for(path)))
|
|
221
|
+
self.assertNotIn('graphcore.scheduling.beat_scheduler', imports)
|
|
222
|
+
self.assertNotIn('BeatScheduler', path.read_text())
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class IssuerNeutralityTests(SimpleTestCase):
|
|
226
|
+
def test_kernel_names_no_identity_provider(self):
|
|
227
|
+
for path in ROOT.rglob('*.py'):
|
|
228
|
+
if '__pycache__' in path.parts:
|
|
229
|
+
continue
|
|
230
|
+
with self.subTest(path=str(path.relative_to(ROOT))):
|
|
231
|
+
self.assertNotIn('key' + 'cloak', path.read_text().lower())
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Tests for graphcore.docs.docs_discovery."""
|
|
2
|
+
from types import SimpleNamespace
|
|
3
|
+
from unittest.mock import MagicMock, patch
|
|
4
|
+
|
|
5
|
+
from django.test import TestCase
|
|
6
|
+
|
|
7
|
+
from graphcore.docs.docs_discovery import (
|
|
8
|
+
DOCS_GROUP,
|
|
9
|
+
SOURCE_NPM,
|
|
10
|
+
SOURCE_PY,
|
|
11
|
+
SOURCE_RENDER,
|
|
12
|
+
Doc,
|
|
13
|
+
discover_doc_topics,
|
|
14
|
+
read_doc,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _fake_eps(*, docs=None):
|
|
19
|
+
fake = MagicMock()
|
|
20
|
+
|
|
21
|
+
def select(group):
|
|
22
|
+
if group == DOCS_GROUP:
|
|
23
|
+
return docs or []
|
|
24
|
+
return []
|
|
25
|
+
|
|
26
|
+
fake.select.side_effect = select
|
|
27
|
+
return fake
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class DiscoverDocTopicsTests(TestCase):
|
|
31
|
+
def test_empty_groups_return_empty_dict(self):
|
|
32
|
+
with patch("graphcore.docs.docs_discovery.entry_points", return_value=_fake_eps()):
|
|
33
|
+
self.assertEqual({}, discover_doc_topics())
|
|
34
|
+
|
|
35
|
+
def test_topics_are_namespaced_by_entry_point(self):
|
|
36
|
+
ep = MagicMock()
|
|
37
|
+
ep.name = "distro"
|
|
38
|
+
ep.load.return_value = SimpleNamespace(
|
|
39
|
+
TOPICS={"readme": Doc("graphcore_user_guides", "getting_started.md", "Setup")}
|
|
40
|
+
)
|
|
41
|
+
with patch("graphcore.docs.docs_discovery.entry_points", return_value=_fake_eps(docs=[ep])):
|
|
42
|
+
result = discover_doc_topics()
|
|
43
|
+
self.assertEqual(["distro/readme"], list(result))
|
|
44
|
+
self.assertEqual(Doc("graphcore_user_guides", "getting_started.md", "Setup"), result["distro/readme"])
|
|
45
|
+
|
|
46
|
+
def test_topic_keys_can_define_subpaths(self):
|
|
47
|
+
ep = MagicMock()
|
|
48
|
+
ep.name = "kernel"
|
|
49
|
+
ep.load.return_value = SimpleNamespace(
|
|
50
|
+
TOPICS={"auth/policy": Doc("graphcore", "authz/README.md", "Policy")}
|
|
51
|
+
)
|
|
52
|
+
with patch("graphcore.docs.docs_discovery.entry_points", return_value=_fake_eps(docs=[ep])):
|
|
53
|
+
result = discover_doc_topics()
|
|
54
|
+
self.assertEqual(["kernel/auth/policy"], list(result))
|
|
55
|
+
|
|
56
|
+
def test_same_topic_id_from_different_packages_never_collides(self):
|
|
57
|
+
ep_a = MagicMock()
|
|
58
|
+
ep_a.name = "aaa"
|
|
59
|
+
ep_a.load.return_value = SimpleNamespace(TOPICS={"readme": Doc("aaa", "readme.md", "from aaa")})
|
|
60
|
+
ep_z = MagicMock()
|
|
61
|
+
ep_z.name = "zzz"
|
|
62
|
+
ep_z.load.return_value = SimpleNamespace(TOPICS={"readme": Doc("zzz", "readme.md", "from zzz")})
|
|
63
|
+
with patch(
|
|
64
|
+
"graphcore.docs.docs_discovery.entry_points",
|
|
65
|
+
return_value=_fake_eps(docs=[ep_z, ep_a]),
|
|
66
|
+
):
|
|
67
|
+
result = discover_doc_topics()
|
|
68
|
+
self.assertEqual("from aaa", result["aaa/readme"].description)
|
|
69
|
+
self.assertEqual("from zzz", result["zzz/readme"].description)
|
|
70
|
+
self.assertEqual(2, len(result))
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class DocSourceTests(TestCase):
|
|
74
|
+
def test_default_source_is_py(self):
|
|
75
|
+
self.assertEqual(SOURCE_PY, Doc("pkg", "readme.md", "Setup").source)
|
|
76
|
+
|
|
77
|
+
def test_npm_source_can_be_set_explicitly(self):
|
|
78
|
+
doc = Doc("@graphcore/react-kernel", "docs/views.md", "Views", source=SOURCE_NPM)
|
|
79
|
+
self.assertEqual(SOURCE_NPM, doc.source)
|
|
80
|
+
|
|
81
|
+
def test_render_source_can_be_set_explicitly(self):
|
|
82
|
+
doc = Doc("graphcore.docs.public_api", "public_api_docs_renderer", "API", source=SOURCE_RENDER)
|
|
83
|
+
self.assertEqual(SOURCE_RENDER, doc.source)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class ReadDocTests(TestCase):
|
|
87
|
+
def test_read_doc_uses_importlib_resources_for_py(self):
|
|
88
|
+
fake_files = MagicMock()
|
|
89
|
+
fake_path = MagicMock()
|
|
90
|
+
fake_path.read_text.return_value = "hello\n"
|
|
91
|
+
fake_files.joinpath.return_value = fake_path
|
|
92
|
+
with patch("graphcore.docs.docs_discovery.resources.files", return_value=fake_files) as files:
|
|
93
|
+
content = read_doc(Doc("pkg.docs", "topic.md", "desc"))
|
|
94
|
+
files.assert_called_once_with("pkg.docs")
|
|
95
|
+
fake_files.joinpath.assert_called_once_with("topic.md")
|
|
96
|
+
fake_path.read_text.assert_called_once_with(encoding="utf-8")
|
|
97
|
+
self.assertEqual("hello\n", content)
|
|
98
|
+
|
|
99
|
+
def test_read_doc_resolves_npm_via_node_modules(self):
|
|
100
|
+
with patch("graphcore.docs.docs_discovery._find_in_node_modules") as find:
|
|
101
|
+
find.return_value.read_text.return_value = "npm hello\n"
|
|
102
|
+
content = read_doc(Doc("@graphcore/react-kernel", "docs/views.md", "Views", source=SOURCE_NPM))
|
|
103
|
+
find.assert_called_once_with("@graphcore/react-kernel", "docs/views.md")
|
|
104
|
+
self.assertEqual("npm hello\n", content)
|
|
105
|
+
|
|
106
|
+
def test_read_doc_calls_the_named_renderer(self):
|
|
107
|
+
content = read_doc(Doc("graphcore.docs.public_api", "public_api_docs_renderer", "API", source=SOURCE_RENDER))
|
|
108
|
+
self.assertIn("## graphcore.public.apps", content)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Step C1: library code logs, it does not print.
|
|
3
|
+
|
|
4
|
+
print() writes go to stdout unconditionally - no level, no timestamp, no
|
|
5
|
+
correlation with the rest of a deployment's logs, and invisible to whatever
|
|
6
|
+
log aggregator a consuming app already runs. CLI subcommands are the
|
|
7
|
+
legitimate exception: their whole job is talking to a human at a terminal.
|
|
8
|
+
"""
|
|
9
|
+
import ast
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from django.test import TestCase
|
|
13
|
+
|
|
14
|
+
import graphcore
|
|
15
|
+
from graphcore.execution.strategy_context import kernel_internal_context
|
|
16
|
+
from graphcore.registry.registry import DEFAULT_REGISTRY
|
|
17
|
+
from graphcore.runtime import django_runtime
|
|
18
|
+
from graphcore.domain.entity.Entity import Entity
|
|
19
|
+
from graphcore.types.identity import Principal
|
|
20
|
+
|
|
21
|
+
PACKAGE_ROOT = Path(graphcore.__file__).resolve().parent
|
|
22
|
+
|
|
23
|
+
# Path segments that are never library runtime code. `cli/` holds every CLI
|
|
24
|
+
# subcommand implementation - their print() calls *are* the user-facing
|
|
25
|
+
# output, not diagnostics.
|
|
26
|
+
EXCLUDED_DIR_SEGMENTS = {"tests", "migrations"}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _iter_library_python_files():
|
|
30
|
+
for path in PACKAGE_ROOT.rglob("*.py"):
|
|
31
|
+
relative = path.relative_to(PACKAGE_ROOT)
|
|
32
|
+
if EXCLUDED_DIR_SEGMENTS & set(relative.parts[:-1]):
|
|
33
|
+
continue
|
|
34
|
+
yield path
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _calls_print(path: Path) -> bool:
|
|
38
|
+
tree = ast.parse(path.read_text(), filename=str(path))
|
|
39
|
+
for node in ast.walk(tree):
|
|
40
|
+
if isinstance(node, ast.Call) and isinstance(node.func, ast.Name) and node.func.id == "print":
|
|
41
|
+
return True
|
|
42
|
+
return False
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class NoPrintInLibraryCodeTest(TestCase):
|
|
46
|
+
def test_no_print_outside_cli_output_paths(self):
|
|
47
|
+
offenders = [str(path.relative_to(PACKAGE_ROOT)) for path in _iter_library_python_files() if _calls_print(path)]
|
|
48
|
+
self.assertEqual(offenders, [], f"print() found in library code: {offenders}")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class EntityServiceEmitsNoStdoutTest(TestCase):
|
|
52
|
+
"""get_entity/save_entity used to print on every call (Step C1)."""
|
|
53
|
+
|
|
54
|
+
TEST_USER_ENTITY_ID = "test-user-entity-id"
|
|
55
|
+
|
|
56
|
+
async def test_save_and_get_entity_write_nothing_to_stdout(self):
|
|
57
|
+
import io
|
|
58
|
+
import contextlib
|
|
59
|
+
|
|
60
|
+
service = django_runtime(DEFAULT_REGISTRY).entity_service
|
|
61
|
+
entity = service.create(Entity)
|
|
62
|
+
principal = Principal(principal_entity_id=self.TEST_USER_ENTITY_ID)
|
|
63
|
+
|
|
64
|
+
captured = io.StringIO()
|
|
65
|
+
with contextlib.redirect_stdout(captured):
|
|
66
|
+
with kernel_internal_context():
|
|
67
|
+
entity = await service.save_entity(entity, principal)
|
|
68
|
+
await service.get_entity(entity.entity_id, principal)
|
|
69
|
+
|
|
70
|
+
self.assertEqual(captured.getvalue(), "")
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Kernel packaging metadata and optional extras."""
|
|
2
|
+
import ast
|
|
3
|
+
from importlib.metadata import metadata
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from django.test import TestCase
|
|
7
|
+
from packaging.version import Version
|
|
8
|
+
|
|
9
|
+
import graphcore
|
|
10
|
+
from graphcore.tests.test_no_print import _iter_library_python_files
|
|
11
|
+
|
|
12
|
+
PACKAGE_ROOT = Path(graphcore.__file__).resolve().parent
|
|
13
|
+
REDIS_EXTRA_MODULES = {"redis", "django_redis", "channels_redis"}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _top_level_imports(path: Path) -> set:
|
|
17
|
+
tree = ast.parse(path.read_text(), filename=str(path))
|
|
18
|
+
names = set()
|
|
19
|
+
for node in tree.body:
|
|
20
|
+
if isinstance(node, ast.Import):
|
|
21
|
+
names.update(alias.name.split(".")[0] for alias in node.names)
|
|
22
|
+
elif isinstance(node, ast.ImportFrom) and node.module:
|
|
23
|
+
names.add(node.module.split(".")[0])
|
|
24
|
+
return names
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class NoModuleLevelRedisImportTest(TestCase):
|
|
28
|
+
def test_no_library_module_imports_redis_packages_at_top_level(self):
|
|
29
|
+
offenders = {
|
|
30
|
+
str(path.relative_to(PACKAGE_ROOT)): hit
|
|
31
|
+
for path in _iter_library_python_files()
|
|
32
|
+
for hit in [_top_level_imports(path) & REDIS_EXTRA_MODULES]
|
|
33
|
+
if hit
|
|
34
|
+
}
|
|
35
|
+
self.assertEqual(offenders, {}, f"module-level redis imports found: {offenders}")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class PackagingMetadataTest(TestCase):
|
|
39
|
+
def test_installed_distribution_has_description_and_license(self):
|
|
40
|
+
dist_metadata = metadata("graphcore-kernel")
|
|
41
|
+
self.assertTrue(dist_metadata.get("Summary"))
|
|
42
|
+
self.assertEqual(dist_metadata.get("License-Expression"), "Apache-2.0")
|
|
43
|
+
self.assertTrue(dist_metadata.get_payload().strip())
|
|
44
|
+
|
|
45
|
+
def test_version(self):
|
|
46
|
+
Version(metadata("graphcore-kernel")["Version"])
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class KernelPackageContentsTest(TestCase):
|
|
50
|
+
def test_no_cli_or_content_dirs(self):
|
|
51
|
+
# Distro-only content trees must not live in the kernel. Kernel-owned
|
|
52
|
+
# ``docs/`` (doc discovery + package topics) is intentional.
|
|
53
|
+
for name in ("cli", "scaffold", "skills", "infra", "scripts"):
|
|
54
|
+
self.assertFalse((PACKAGE_ROOT / name).exists(), f"kernel still has {name}/")
|
|
55
|
+
|
|
56
|
+
def test_no_runner_or_deployment(self):
|
|
57
|
+
self.assertFalse((PACKAGE_ROOT / "runner.py").exists())
|
|
58
|
+
self.assertFalse((PACKAGE_ROOT / "deployment.py").exists())
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class NoConfDefaultsModuleTest(TestCase):
|
|
62
|
+
def test_conf_defaults_does_not_exist(self):
|
|
63
|
+
with self.assertRaises(ModuleNotFoundError):
|
|
64
|
+
import graphcore.conf.defaults # noqa: F401
|