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.
Files changed (343) hide show
  1. graphcore/__init__.py +5 -0
  2. graphcore/agent_frontend/__init__.py +8 -0
  3. graphcore/agent_frontend/api.py +69 -0
  4. graphcore/agent_frontend/base/__init__.py +11 -0
  5. graphcore/agent_frontend/base/views.py +167 -0
  6. graphcore/agent_frontend/client.py +31 -0
  7. graphcore/agent_frontend/context.py +157 -0
  8. graphcore/agent_frontend/errors.py +12 -0
  9. graphcore/agent_frontend/loading.py +54 -0
  10. graphcore/agent_frontend/registry.py +42 -0
  11. graphcore/agent_frontend/render.py +207 -0
  12. graphcore/agent_frontend/server.py +103 -0
  13. graphcore/agent_frontend/signatures.py +35 -0
  14. graphcore/agent_frontend/testing.py +45 -0
  15. graphcore/agent_frontend/tests/__init__.py +0 -0
  16. graphcore/agent_frontend/tests/fakes.py +114 -0
  17. graphcore/agent_frontend/tests/test_frontend.py +447 -0
  18. graphcore/agent_frontend/tests/test_loading.py +83 -0
  19. graphcore/agent_frontend/tests/test_server.py +109 -0
  20. graphcore/agent_frontend/tools.py +137 -0
  21. graphcore/api/__init__.py +4 -0
  22. graphcore/api/graph_api.py +378 -0
  23. graphcore/api/predicate_codec.py +81 -0
  24. graphcore/api/tests/__init__.py +0 -0
  25. graphcore/api/tests/test_changed_entities.py +109 -0
  26. graphcore/api/tests/test_graph_api.py +290 -0
  27. graphcore/api/tests/test_graph_api_access.py +94 -0
  28. graphcore/api/tests/test_graph_api_grants.py +90 -0
  29. graphcore/api/tests/test_predicate_codec.py +83 -0
  30. graphcore/api/tests/test_subtree_query.py +79 -0
  31. graphcore/apps.py +71 -0
  32. graphcore/auth/__init__.py +1 -0
  33. graphcore/auth/authn/README.md +178 -0
  34. graphcore/auth/authn/__init__.py +3 -0
  35. graphcore/auth/authn/authenticator.py +120 -0
  36. graphcore/auth/authn/onboarding.py +105 -0
  37. graphcore/auth/authn/principals.py +20 -0
  38. graphcore/auth/authn/resource_metadata.py +43 -0
  39. graphcore/auth/authn/service_accounts.py +96 -0
  40. graphcore/auth/authn/testing.py +96 -0
  41. graphcore/auth/authn/tests/__init__.py +0 -0
  42. graphcore/auth/authn/tests/test_authenticator.py +145 -0
  43. graphcore/auth/authn/tests/test_onboarding.py +145 -0
  44. graphcore/auth/authn/tests/test_service_accounts.py +180 -0
  45. graphcore/auth/authn/users.py +59 -0
  46. graphcore/auth/authz/__init__.py +0 -0
  47. graphcore/auth/authz/access_port.py +120 -0
  48. graphcore/auth/authz/adapter/__init__.py +0 -0
  49. graphcore/auth/authz/adapter/default_access_adapter.py +556 -0
  50. graphcore/auth/authz/adapter/tests/__init__.py +0 -0
  51. graphcore/auth/authz/adapter/tests/test_default_adapter.py +543 -0
  52. graphcore/auth/authz/adapter/tests/test_entity_write_hooks.py +207 -0
  53. graphcore/auth/authz/adapter/tests/test_group_types.py +70 -0
  54. graphcore/auth/authz/adapter/tests/test_sync_support.py +209 -0
  55. graphcore/auth/authz/defaults.py +26 -0
  56. graphcore/auth/authz/kernel_policy.py +191 -0
  57. graphcore/auth/authz/kernel_writes.py +31 -0
  58. graphcore/auth/authz/lookups.py +25 -0
  59. graphcore/auth/authz/policy.py +403 -0
  60. graphcore/auth/authz/tests/__init__.py +0 -0
  61. graphcore/auth/authz/tests/test_can_contain.py +150 -0
  62. graphcore/auth/authz/tests/test_contained_by.py +167 -0
  63. graphcore/auth/authz/tests/test_creation.py +391 -0
  64. graphcore/auth/authz/tests/test_delete_permission.py +82 -0
  65. graphcore/auth/authz/tests/test_granted_to_me.py +160 -0
  66. graphcore/auth/authz/tests/test_integration.py +637 -0
  67. graphcore/auth/authz/tests/test_invites.py +184 -0
  68. graphcore/auth/authz/tests/test_kernel_policy.py +140 -0
  69. graphcore/auth/authz/tests/test_lockout.py +132 -0
  70. graphcore/auth/authz/tests/test_policy.py +329 -0
  71. graphcore/auth/authz/tests/test_primitives.py +73 -0
  72. graphcore/auth/authz/tests/test_principal_creation.py +62 -0
  73. graphcore/bootstrap/__init__.py +0 -0
  74. graphcore/bootstrap/deployment.py +67 -0
  75. graphcore/bootstrap/signals.py +16 -0
  76. graphcore/bootstrap/tests/__init__.py +0 -0
  77. graphcore/bootstrap/tests/test_deployment_seed.py +154 -0
  78. graphcore/broadcast/__init__.py +4 -0
  79. graphcore/broadcast/broadcaster.py +201 -0
  80. graphcore/broadcast/channels.py +56 -0
  81. graphcore/broadcast/tests/__init__.py +0 -0
  82. graphcore/broadcast/tests/test_broadcaster.py +444 -0
  83. graphcore/celery.py +14 -0
  84. graphcore/docs/AGENT_FRONTEND_TDD.md +389 -0
  85. graphcore/docs/ARCHITECTURE_PRINCIPLES.md +152 -0
  86. graphcore/docs/AUTHORIZATION_TECHNICAL_TDD.md +1379 -0
  87. graphcore/docs/ENTITY_REFERENCE_TDD.md +561 -0
  88. graphcore/docs/GRAPHAPI_FRONT_DOOR.md +173 -0
  89. graphcore/docs/RUNTIME.md +90 -0
  90. graphcore/docs/SCHEDULING_TDD.md +244 -0
  91. graphcore/docs/STRATEGY_EXECUTION_TDD.md +1043 -0
  92. graphcore/docs/VIEW_ENTITY_TDD.md +522 -0
  93. graphcore/docs/VIEW_SYSTEM_TDD.md +307 -0
  94. graphcore/docs/__init__.py +0 -0
  95. graphcore/docs/doc_topics.py +97 -0
  96. graphcore/docs/docs_discovery.py +64 -0
  97. graphcore/docs/public_api.py +56 -0
  98. graphcore/domain/__init__.py +0 -0
  99. graphcore/domain/entity/Entity.py +204 -0
  100. graphcore/domain/entity/__init__.py +0 -0
  101. graphcore/domain/entity/deployment/Deployment.py +25 -0
  102. graphcore/domain/entity/deployment/__init__.py +0 -0
  103. graphcore/domain/entity/grant/Grant.py +31 -0
  104. graphcore/domain/entity/grant/__init__.py +0 -0
  105. graphcore/domain/entity/group/Group.py +48 -0
  106. graphcore/domain/entity/group/README.md +88 -0
  107. graphcore/domain/entity/group/__init__.py +0 -0
  108. graphcore/domain/entity/invite/Invite.py +31 -0
  109. graphcore/domain/entity/invite/__init__.py +0 -0
  110. graphcore/domain/entity/request_template/RequestTemplate.py +48 -0
  111. graphcore/domain/entity/request_template/__init__.py +0 -0
  112. graphcore/domain/entity/request_template/tests/__init__.py +0 -0
  113. graphcore/domain/entity/request_template/tests/test_request_template.py +52 -0
  114. graphcore/domain/entity/service_account/ServiceAccount.py +41 -0
  115. graphcore/domain/entity/service_account/__init__.py +0 -0
  116. graphcore/domain/entity/strategy_request/StrategyRequest.py +61 -0
  117. graphcore/domain/entity/strategy_request/__init__.py +0 -0
  118. graphcore/domain/entity/strategy_request/tests/__init__.py +0 -0
  119. graphcore/domain/entity/strategy_request/tests/test_strategy_request_entity.py +35 -0
  120. graphcore/domain/entity/tests/__init__.py +0 -0
  121. graphcore/domain/entity/tests/test_entity.py +227 -0
  122. graphcore/domain/entity/tests/test_grant_group_entities.py +36 -0
  123. graphcore/domain/entity/tests/test_write_once_fields.py +98 -0
  124. graphcore/domain/entity/user/User.py +39 -0
  125. graphcore/domain/entity/user/__init__.py +0 -0
  126. graphcore/domain/entity/user/tests/__init__.py +0 -0
  127. graphcore/domain/entity/user/tests/test_user_entity.py +33 -0
  128. graphcore/domain/entity/view/View.py +37 -0
  129. graphcore/domain/entity/view/__init__.py +0 -0
  130. graphcore/domain/entity/view/position.py +78 -0
  131. graphcore/domain/entity/view/tests/__init__.py +0 -0
  132. graphcore/domain/entity/view/tests/test_position.py +71 -0
  133. graphcore/domain/entity/view/tests/test_view_entity.py +134 -0
  134. graphcore/domain/strategy/BaseStrategy.py +759 -0
  135. graphcore/domain/strategy/DeploymentStrategies.py +55 -0
  136. graphcore/domain/strategy/GrantStrategies.py +189 -0
  137. graphcore/domain/strategy/GroupStrategies.py +193 -0
  138. graphcore/domain/strategy/InviteStrategies.py +84 -0
  139. graphcore/domain/strategy/RequestTemplateStrategies.py +126 -0
  140. graphcore/domain/strategy/ViewStrategies.py +219 -0
  141. graphcore/domain/strategy/__init__.py +0 -0
  142. graphcore/domain/strategy/runner.py +84 -0
  143. graphcore/domain/strategy/session.py +56 -0
  144. graphcore/domain/strategy/tests/BaseStrategyTest.py +167 -0
  145. graphcore/domain/strategy/tests/__init__.py +0 -0
  146. graphcore/domain/strategy/tests/test_BaseStrategies.py +870 -0
  147. graphcore/domain/strategy/tests/test_grant_strategies.py +245 -0
  148. graphcore/domain/strategy/tests/test_group_strategies.py +99 -0
  149. graphcore/domain/strategy/tests/test_runner.py +220 -0
  150. graphcore/domain/strategy/tests/test_strategy_locks.py +446 -0
  151. graphcore/domain/strategy/tests/test_utils.py +95 -0
  152. graphcore/domain/strategy/tests/test_view_strategies.py +436 -0
  153. graphcore/errors.py +145 -0
  154. graphcore/execution/README.md +97 -0
  155. graphcore/execution/StrategyExecutorService.py +333 -0
  156. graphcore/execution/__init__.py +0 -0
  157. graphcore/execution/dispatcher.py +19 -0
  158. graphcore/execution/environments/__init__.py +0 -0
  159. graphcore/execution/environments/celery.py +59 -0
  160. graphcore/execution/environments/in_process.py +55 -0
  161. graphcore/execution/local_session.py +117 -0
  162. graphcore/execution/redis_run_events.py +74 -0
  163. graphcore/execution/requests.py +22 -0
  164. graphcore/execution/run_events.py +85 -0
  165. graphcore/execution/strategy_context.py +54 -0
  166. graphcore/execution/tasks.py +34 -0
  167. graphcore/execution/tests/__init__.py +5 -0
  168. graphcore/execution/tests/contract.py +171 -0
  169. graphcore/execution/tests/support.py +310 -0
  170. graphcore/execution/tests/test_dispatchers.py +76 -0
  171. graphcore/execution/tests/test_executor.py +368 -0
  172. graphcore/execution/tests/test_local_session.py +95 -0
  173. graphcore/execution/tests/test_reconcile_runs.py +134 -0
  174. graphcore/execution/tests/test_run_events.py +106 -0
  175. graphcore/execution/tests/test_strategy_context.py +62 -0
  176. graphcore/gateway/__init__.py +1 -0
  177. graphcore/gateway/remote.py +35 -0
  178. graphcore/gateway/tests/__init__.py +0 -0
  179. graphcore/gateway/tests/test_remote.py +30 -0
  180. graphcore/graph/EntityService.py +710 -0
  181. graphcore/graph/__init__.py +0 -0
  182. graphcore/graph/entity_cache.py +152 -0
  183. graphcore/graph/tests/__init__.py +4 -0
  184. graphcore/graph/tests/test_EntityService.py +908 -0
  185. graphcore/graph/tests/test_EntityService_list.py +170 -0
  186. graphcore/graph/tests/test_EntityService_model_resolution.py +339 -0
  187. graphcore/graph/tests/test_EntityService_referrers.py +236 -0
  188. graphcore/graph/tests/test_EntityService_routing.py +119 -0
  189. graphcore/graph/tests/test_dependent_on.py +141 -0
  190. graphcore/graph/tests/test_engine_is_type_agnostic.py +25 -0
  191. graphcore/graph/tests/test_engine_resolves_read_permission.py +93 -0
  192. graphcore/graph/tests/test_entity_cache.py +159 -0
  193. graphcore/graph/tests/test_null_entity_cache.py +12 -0
  194. graphcore/management/__init__.py +0 -0
  195. graphcore/management/commands/__init__.py +0 -0
  196. graphcore/management/commands/dev_reset.py +18 -0
  197. graphcore/management/commands/graphcore_createadmin.py +65 -0
  198. graphcore/management/commands/graphcore_policy.py +59 -0
  199. graphcore/management/commands/graphcore_status.py +98 -0
  200. graphcore/management/tests/__init__.py +0 -0
  201. graphcore/management/tests/test_createadmin.py +78 -0
  202. graphcore/management/tests/test_policy_command.py +46 -0
  203. graphcore/management/tests/test_status_command.py +85 -0
  204. graphcore/migrations/0001_initial.py +186 -0
  205. graphcore/migrations/0002_invite.py +26 -0
  206. graphcore/migrations/__init__.py +0 -0
  207. graphcore/models.py +11 -0
  208. graphcore/persistence/ENTITY_REPOSITORY_TECHNICAL_TDD.md +396 -0
  209. graphcore/persistence/__init__.py +6 -0
  210. graphcore/persistence/django/__init__.py +0 -0
  211. graphcore/persistence/django/backends.py +43 -0
  212. graphcore/persistence/django/bindings.py +28 -0
  213. graphcore/persistence/django/cache.py +38 -0
  214. graphcore/persistence/django/compiler.py +214 -0
  215. graphcore/persistence/django/identity.py +18 -0
  216. graphcore/persistence/django/models.py +252 -0
  217. graphcore/persistence/django/repository.py +525 -0
  218. graphcore/persistence/django/tests/__init__.py +0 -0
  219. graphcore/persistence/django/tests/test_backends.py +68 -0
  220. graphcore/persistence/django/tests/test_compiler.py +269 -0
  221. graphcore/persistence/django/tests/test_repository.py +472 -0
  222. graphcore/persistence/django/tests/test_shared_column.py +120 -0
  223. graphcore/persistence/django/tests/test_threads.py +50 -0
  224. graphcore/persistence/django/tests/test_update_shape.py +175 -0
  225. graphcore/persistence/django/threads.py +38 -0
  226. graphcore/persistence/repository.py +172 -0
  227. graphcore/persistence/tests/__init__.py +0 -0
  228. graphcore/persistence/tests/contract.py +688 -0
  229. graphcore/persistence/tests/evaluate.py +51 -0
  230. graphcore/persistence/tests/fixtures.py +32 -0
  231. graphcore/persistence/tests/memory.py +263 -0
  232. graphcore/persistence/tests/test_memory_repository.py +10 -0
  233. graphcore/persistence/tests/test_query_types.py +127 -0
  234. graphcore/public/__init__.py +9 -0
  235. graphcore/public/api.py +9 -0
  236. graphcore/public/apps.py +10 -0
  237. graphcore/public/auth/__init__.py +1 -0
  238. graphcore/public/auth/grants.py +7 -0
  239. graphcore/public/auth/onboarding.py +8 -0
  240. graphcore/public/auth/perms.py +7 -0
  241. graphcore/public/auth/policy.py +10 -0
  242. graphcore/public/auth/roles.py +8 -0
  243. graphcore/public/auth/subjects.py +7 -0
  244. graphcore/public/entities/__init__.py +32 -0
  245. graphcore/public/errors.py +19 -0
  246. graphcore/public/persistence/__init__.py +44 -0
  247. graphcore/public/persistence/django.py +24 -0
  248. graphcore/public/scheduling.py +23 -0
  249. graphcore/public/strategies/__init__.py +85 -0
  250. graphcore/public/test_settings.py +16 -0
  251. graphcore/public/testing.py +47 -0
  252. graphcore/registry/EntityDirectory.py +246 -0
  253. graphcore/registry/README.md +147 -0
  254. graphcore/registry/StrategyDirectory.py +308 -0
  255. graphcore/registry/TYPE_METADATA_PLACEMENT.md +66 -0
  256. graphcore/registry/__init__.py +0 -0
  257. graphcore/registry/app_discovery.py +108 -0
  258. graphcore/registry/decorators.py +77 -0
  259. graphcore/registry/discovery.py +111 -0
  260. graphcore/registry/registry.py +79 -0
  261. graphcore/registry/tests/__init__.py +0 -0
  262. graphcore/registry/tests/test_agent_frontend_discovery.py +56 -0
  263. graphcore/registry/tests/test_app_config.py +36 -0
  264. graphcore/registry/tests/test_discovery.py +147 -0
  265. graphcore/registry/tests/test_entity_directory_storage.py +73 -0
  266. graphcore/registry/tests/test_import_package.py +87 -0
  267. graphcore/registry/tests/test_principal_flag.py +67 -0
  268. graphcore/registry/tests/test_strategy_directory.py +29 -0
  269. graphcore/routes/__init__.py +116 -0
  270. graphcore/routes/tests/__init__.py +0 -0
  271. graphcore/routes/tests/test_routes.py +90 -0
  272. graphcore/runtime.py +243 -0
  273. graphcore/scheduling/__init__.py +0 -0
  274. graphcore/scheduling/beat_scheduler.py +164 -0
  275. graphcore/scheduling/beat_tasks.py +63 -0
  276. graphcore/scheduling/scheduler.py +37 -0
  277. graphcore/scheduling/tests/__init__.py +0 -0
  278. graphcore/scheduling/tests/contract.py +136 -0
  279. graphcore/scheduling/tests/memory.py +42 -0
  280. graphcore/scheduling/tests/test_beat_scheduler.py +87 -0
  281. graphcore/scheduling/tests/test_memory_scheduler.py +15 -0
  282. graphcore/scheduling/tests/test_ticks.py +143 -0
  283. graphcore/tasks.py +9 -0
  284. graphcore/test_settings.py +78 -0
  285. graphcore/testing/__init__.py +0 -0
  286. graphcore/testing/case.py +112 -0
  287. graphcore/testing/runner.py +32 -0
  288. graphcore/testing/settings.py +26 -0
  289. graphcore/testing/tests/__init__.py +0 -0
  290. graphcore/testing/tests/agent_view_fixture.py +19 -0
  291. graphcore/testing/tests/test_case_and_runner.py +219 -0
  292. graphcore/testing/tests/test_settings_for_apps.py +50 -0
  293. graphcore/tests/__init__.py +0 -0
  294. graphcore/tests/ids.py +14 -0
  295. graphcore/tests/public_api_manifest.py +102 -0
  296. graphcore/tests/runs.py +7 -0
  297. graphcore/tests/test_app_discovery.py +90 -0
  298. graphcore/tests/test_composition_boundaries.py +231 -0
  299. graphcore/tests/test_docs_discovery.py +108 -0
  300. graphcore/tests/test_no_print.py +70 -0
  301. graphcore/tests/test_packaging.py +64 -0
  302. graphcore/tests/test_public_api_boundaries.py +229 -0
  303. graphcore/tests/test_public_api_contract.py +62 -0
  304. graphcore/tests/test_public_api_docs.py +28 -0
  305. graphcore/tests/test_runtime.py +42 -0
  306. graphcore/tests/test_shared_type_boundaries.py +128 -0
  307. graphcore/tests/test_shared_types.py +144 -0
  308. graphcore/tests/test_test_settings.py +45 -0
  309. graphcore/transport/__init__.py +0 -0
  310. graphcore/transport/agent_asgi.py +68 -0
  311. graphcore/transport/agent_client.py +85 -0
  312. graphcore/transport/channel_layer.py +68 -0
  313. graphcore/transport/consumers.py +507 -0
  314. graphcore/transport/routing.py +6 -0
  315. graphcore/transport/tests/__init__.py +0 -0
  316. graphcore/transport/tests/test_agent_client.py +31 -0
  317. graphcore/transport/tests/test_api_views.py +733 -0
  318. graphcore/transport/tests/test_channel_layer.py +96 -0
  319. graphcore/transport/tests/test_consumers.py +963 -0
  320. graphcore/transport/tests/test_resource_metadata.py +67 -0
  321. graphcore/transport/urls.py +29 -0
  322. graphcore/transport/views.py +358 -0
  323. graphcore/types/__init__.py +4 -0
  324. graphcore/types/access.py +114 -0
  325. graphcore/types/api.py +76 -0
  326. graphcore/types/entities.py +100 -0
  327. graphcore/types/entity_id.py +85 -0
  328. graphcore/types/execution.py +41 -0
  329. graphcore/types/identity.py +20 -0
  330. graphcore/types/onboarding.py +20 -0
  331. graphcore/types/query.py +116 -0
  332. graphcore/types/schedules.py +91 -0
  333. graphcore/types/strategy.py +73 -0
  334. graphcore/types/tests/__init__.py +0 -0
  335. graphcore/types/tests/test_entity_id.py +50 -0
  336. graphcore/urls.py +5 -0
  337. graphcore_kernel-0.1.0.dist-info/METADATA +94 -0
  338. graphcore_kernel-0.1.0.dist-info/RECORD +343 -0
  339. graphcore_kernel-0.1.0.dist-info/WHEEL +5 -0
  340. graphcore_kernel-0.1.0.dist-info/entry_points.txt +2 -0
  341. graphcore_kernel-0.1.0.dist-info/licenses/LICENSE +202 -0
  342. graphcore_kernel-0.1.0.dist-info/licenses/NOTICE +2 -0
  343. graphcore_kernel-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,43 @@
1
+ """The databases the Django repository is tested on and will run against.
2
+
3
+ Behaviour differences are decided by Django's feature flags
4
+ (`connection.features`) wherever Django has one; `connection.vendor` is
5
+ consulted only where it has no portable answer (e.g. GIN indexes). Adding a
6
+ database here also adds it to `scripts/test`'s matrix.
7
+ """
8
+ from django.core import checks
9
+ from django.core.exceptions import ImproperlyConfigured
10
+ from django.db import connections
11
+
12
+ SUPPORTED_VENDORS = ('postgresql', 'sqlite')
13
+ REFERENCE_VENDOR = 'postgresql'
14
+
15
+
16
+ def _unsupported_message(vendor: str) -> str:
17
+ return (
18
+ f"GraphCore's Django repository does not support the {vendor!r} database; "
19
+ f"supported: {', '.join(SUPPORTED_VENDORS)}."
20
+ )
21
+
22
+
23
+ def check_supported(connection) -> None:
24
+ if connection.vendor not in SUPPORTED_VENDORS:
25
+ raise ImproperlyConfigured(_unsupported_message(connection.vendor))
26
+
27
+
28
+ def is_unique_violation(error) -> bool:
29
+ """Django raises one `IntegrityError` for every constraint kind; only the
30
+ driver's error says which."""
31
+ cause = error.__cause__
32
+ if getattr(cause, 'sqlstate', None) == '23505' or getattr(cause, 'pgcode', None) == '23505':
33
+ return True
34
+ return 'UNIQUE constraint failed' in str(error)
35
+
36
+
37
+ def check_database_vendor(app_configs=None, **kwargs) -> list:
38
+ """Django system check: an unsupported database is reported by `check`,
39
+ `migrate` and `test` before anything touches it."""
40
+ vendor = connections['default'].vendor
41
+ if vendor in SUPPORTED_VENDORS:
42
+ return []
43
+ return [checks.Error(_unsupported_message(vendor), id='graphcore.E001')]
@@ -0,0 +1,28 @@
1
+ """Kernel type storage bindings for the Django repository."""
2
+ from graphcore.domain.entity.Entity import Entity
3
+ from graphcore.domain.entity.deployment.Deployment import Deployment
4
+ from graphcore.domain.entity.grant.Grant import Grant
5
+ from graphcore.domain.entity.group.Group import Group
6
+ from graphcore.domain.entity.invite.Invite import Invite
7
+ from graphcore.domain.entity.request_template.RequestTemplate import RequestTemplate
8
+ from graphcore.domain.entity.service_account.ServiceAccount import ServiceAccount
9
+ from graphcore.domain.entity.strategy_request.StrategyRequest import StrategyRequest
10
+ from graphcore.domain.entity.user.User import User
11
+ from graphcore.domain.entity.view.View import View
12
+ from graphcore.persistence.django.models import (
13
+ DeploymentModel, EntityModel, GrantModel, GroupModel, InviteModel, RequestTemplateModel,
14
+ ServiceAccountModel, StrategyRequestModel, UserModel, ViewModel,
15
+ )
16
+
17
+
18
+ def configure(entities) -> None:
19
+ entities.bind_storage(Entity, EntityModel)
20
+ entities.bind_storage(Grant, GrantModel)
21
+ entities.bind_storage(Group, GroupModel)
22
+ entities.bind_storage(Invite, InviteModel)
23
+ entities.bind_storage(Deployment, DeploymentModel)
24
+ entities.bind_storage(User, UserModel)
25
+ entities.bind_storage(ServiceAccount, ServiceAccountModel)
26
+ entities.bind_storage(View, ViewModel)
27
+ entities.bind_storage(StrategyRequest, StrategyRequestModel)
28
+ entities.bind_storage(RequestTemplate, RequestTemplateModel)
@@ -0,0 +1,38 @@
1
+ """`EntityCache` over `django.core.cache`."""
2
+ from __future__ import annotations
3
+
4
+ from django.core.cache import cache as django_cache
5
+
6
+ from graphcore.graph.entity_cache import EntityCache
7
+
8
+
9
+ class DjangoCache(EntityCache):
10
+ """The eight generic primitives over Django's configured cache backend."""
11
+
12
+ def __init__(self, entity_ttl: int):
13
+ super().__init__(entity_ttl)
14
+ self.cache = django_cache
15
+
16
+ def get(self, key):
17
+ return self.cache.get(key)
18
+
19
+ def set(self, key, value, timeout=None):
20
+ self.cache.set(key, value, timeout)
21
+
22
+ def delete(self, key):
23
+ self.cache.delete(key)
24
+
25
+ def get_many(self, keys):
26
+ return self.cache.get_many(keys)
27
+
28
+ def set_many(self, key_value_dict, timeout=None):
29
+ self.cache.set_many(key_value_dict, timeout)
30
+
31
+ def delete_many(self, keys):
32
+ self.cache.delete_many(keys)
33
+
34
+ def add(self, key, value, timeout=None):
35
+ self.cache.add(key, value, timeout)
36
+
37
+ def incr(self, key):
38
+ return self.cache.incr(key)
@@ -0,0 +1,214 @@
1
+ """Predicate -> Django `Q` compilation.
2
+
3
+ Filterable fields are derived from the entity directory's bound models, not
4
+ hardcoded here - any column on any bound model (kernel or app) is
5
+ filterable by name, with no persistence code beyond the binding. An exact
6
+ node-type table (no MRO fallback) governs which predicate shapes exist;
7
+ anything outside either raises before a query runs, so a predicate is never
8
+ silently narrowed or dropped.
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import operator
13
+ from functools import reduce
14
+
15
+ from django.db import connection
16
+ from django.db.models import BooleanField, JSONField, Q
17
+ from django.db.models.expressions import RawSQL
18
+
19
+ from graphcore.errors import InvalidQuery, UnsupportedQuery
20
+ from graphcore.persistence.django.models import EntityModel
21
+ from graphcore.types.query import (
22
+ LITERAL_TYPES, AllOf, AnyOf, ContainsAny, ContainsValue, Equal, InValues, Predicate,
23
+ )
24
+
25
+ NOTHING = Q(pk__in=[])
26
+
27
+
28
+ def _literal(value):
29
+ if not isinstance(value, LITERAL_TYPES):
30
+ raise InvalidQuery(f"{type(value).__name__} is not a supported literal type")
31
+ return value
32
+
33
+
34
+ class QueryCompiler:
35
+ """Compiles predicates against the models bound in `entity_directory`.
36
+
37
+ `_paths` is built lazily on first `compile()` (bindings settle at
38
+ startup, not at import time) and cached for the compiler's lifetime:
39
+ `{attname: [(prefix, field, model), ...]}`, where `prefix` is `''` for a
40
+ column on the base `EntityModel` and `'<model_name>__'` for an MTI child
41
+ column reached through the reverse join.
42
+
43
+ A field name resolves against every bound model, unless an enclosing
44
+ `AllOf` pins `entity_type_id`: every row it matches is then one of those
45
+ types, so its names resolve against those types' models alone. A name
46
+ several pinned types declare matches any of their columns; unpinned, a
47
+ shared name is refused, so installing an app never widens a query.
48
+ """
49
+
50
+ def __init__(self, entity_directory) -> None:
51
+ self.entity_directory = entity_directory
52
+ self._paths = None
53
+
54
+ def _build_paths(self) -> dict:
55
+ paths: dict = {}
56
+ for model in self.entity_directory.storage_classes():
57
+ prefix = '' if model is EntityModel else f'{model._meta.model_name}__'
58
+ for f in model._meta.local_concrete_fields:
59
+ if not f.primary_key or model is EntityModel:
60
+ paths.setdefault(f.attname, []).append((prefix, f, model))
61
+ return paths
62
+
63
+ def _columns(self, field: str, models=None) -> list:
64
+ """Every `(prefix, field)` the name resolves to - more than one only
65
+ under a type pin, and only when those columns share a type."""
66
+ if self._paths is None:
67
+ self._paths = self._build_paths()
68
+ matches = self._paths.get(field, [])
69
+ if models is not None:
70
+ matches = [m for m in matches if m[2] is EntityModel or m[2] in models]
71
+ if not matches:
72
+ raise UnsupportedQuery(f"'{field}' is not a filterable entity field")
73
+ if len(matches) > 1:
74
+ if models is None:
75
+ raise UnsupportedQuery(
76
+ f"'{field}' is ambiguous across bound models - filter on "
77
+ f"entity_type_id alongside it to scope it"
78
+ )
79
+ if len({f.get_internal_type() for _, f, _ in matches}) > 1:
80
+ raise UnsupportedQuery(
81
+ f"'{field}' has different column types across the filtered types"
82
+ )
83
+ return [(prefix, f) for prefix, f, _ in matches]
84
+
85
+ def _pinned_models(self, predicates):
86
+ """The models an `entity_type_id` filter among these conjuncts pins
87
+ them to (each bound model plus its MTI parents), or None."""
88
+ for p in predicates:
89
+ if getattr(p, 'field', None) != 'entity_type_id':
90
+ continue
91
+ if isinstance(p, Equal) and p.value is not None:
92
+ type_ids = {p.value}
93
+ elif isinstance(p, InValues):
94
+ type_ids = p.values
95
+ else:
96
+ continue
97
+ models = set()
98
+ for type_id in type_ids:
99
+ entity_cls = self.entity_directory.get_entity_class(type_id)
100
+ if entity_cls is None:
101
+ continue
102
+ model = self.entity_directory.storage(entity_cls)
103
+ models.add(model)
104
+ models.update(model._meta.get_parent_list())
105
+ if models:
106
+ return frozenset(models)
107
+ return None
108
+
109
+ def _collection(self, field: str, models=None):
110
+ """`(prefix, field)` of a JSON array column - the PostgreSQL path
111
+ would otherwise silently accept a scalar. A child table's column is
112
+ a collection only under a type pin, which guarantees every row
113
+ matched has that child row."""
114
+ columns = self._columns(field, models)
115
+ prefix, f = columns[0]
116
+ if len(columns) > 1 or not (isinstance(f, JSONField) and f.default is list):
117
+ raise UnsupportedQuery(f"'{field}' is not a collection field")
118
+ if f.model is not EntityModel and (models is None or f.model not in models):
119
+ raise UnsupportedQuery(
120
+ f"'{field}' is a column of {f.model.__name__} - filter on entity_type_id alongside it"
121
+ )
122
+ return prefix, f
123
+
124
+ @staticmethod
125
+ def _table(model) -> str:
126
+ return f'"{model._meta.db_table}"'
127
+
128
+ def _json_holds_any(self, field: str, values, models=None) -> Q:
129
+ """`field` overlaps `values`: Django's JSON `contains` where the
130
+ database supports it (indexed on PostgreSQL), otherwise a
131
+ `json_each` scan (SQLite) - the one place the backends diverge."""
132
+ prefix, f = self._collection(field, models)
133
+ if connection.features.supports_json_field_contains:
134
+ clauses = Q()
135
+ for value in values:
136
+ clauses |= Q(**{f'{prefix}{f.attname}__contains': [value]})
137
+ return clauses
138
+ placeholders = ', '.join(['%s'] * len(values))
139
+ column = f'{self._table(f.model)}."{f.column}"'
140
+ if f.model is EntityModel:
141
+ sql = f'EXISTS (SELECT 1 FROM json_each({column}) WHERE json_each.value IN ({placeholders}))'
142
+ else:
143
+ sql = (
144
+ f'{self._table(EntityModel)}."{EntityModel._meta.pk.column}" IN '
145
+ f'(SELECT {self._table(f.model)}."{f.model._meta.pk.column}" '
146
+ f'FROM {self._table(f.model)}, json_each({column}) '
147
+ f'WHERE json_each.value IN ({placeholders}))'
148
+ )
149
+ return Q(RawSQL(sql, list(values), output_field=BooleanField()))
150
+
151
+ @staticmethod
152
+ def _equal_column(prefix: str, f, value) -> Q:
153
+ if value is None:
154
+ if prefix:
155
+ # Child-table null-check hazard: a `LEFT OUTER JOIN` row that
156
+ # doesn't exist for this entity is also "null" on every
157
+ # child column, so without pinning the join itself,
158
+ # `Equal(child_field, None)` would match every other type
159
+ # too.
160
+ return Q(**{f'{prefix}isnull': False, f'{prefix}{f.attname}__isnull': True})
161
+ return Q(**{f'{f.attname}__isnull': True})
162
+ return Q(**{f'{prefix}{f.attname}': value})
163
+
164
+ def _equal(self, node: Equal, models) -> Q:
165
+ columns = self._columns(node.field, models)
166
+ value = _literal(node.value)
167
+ return reduce(operator.or_, (self._equal_column(p, f, value) for p, f in columns))
168
+
169
+ def _in_values(self, node: InValues, models) -> Q:
170
+ columns = self._columns(node.field, models)
171
+ values = [_literal(value) for value in node.values]
172
+ if not values:
173
+ return NOTHING
174
+ return reduce(operator.or_, (Q(**{f'{p}{f.attname}__in': values}) for p, f in columns))
175
+
176
+ def _contains_value(self, node: ContainsValue, models) -> Q:
177
+ return self._json_holds_any(node.field, [_literal(node.value)], models)
178
+
179
+ def _contains_any(self, node: ContainsAny, models) -> Q:
180
+ self._collection(node.field, models)
181
+ values = [_literal(value) for value in node.values]
182
+ return self._json_holds_any(node.field, values, models) if values else NOTHING
183
+
184
+ def _all_of(self, node: AllOf, models) -> Q:
185
+ models = self._pinned_models(node.predicates) or models
186
+ combined = Q()
187
+ for child in node.predicates:
188
+ combined &= self.compile(child, models)
189
+ return combined
190
+
191
+ def _any_of(self, node: AnyOf, models) -> Q:
192
+ if not node.predicates:
193
+ return NOTHING
194
+ combined = Q(pk__in=[])
195
+ for child in node.predicates:
196
+ combined |= self.compile(child, models)
197
+ return combined
198
+
199
+ _HANDLERS = {
200
+ Equal: _equal,
201
+ InValues: _in_values,
202
+ ContainsValue: _contains_value,
203
+ ContainsAny: _contains_any,
204
+ AllOf: _all_of,
205
+ AnyOf: _any_of,
206
+ }
207
+
208
+ def compile(self, predicate: Predicate, models=None) -> Q:
209
+ """`models` narrows field-name resolution - set by an enclosing
210
+ `AllOf`'s type pin, never by callers."""
211
+ handler = self._HANDLERS.get(type(predicate))
212
+ if handler is None:
213
+ raise UnsupportedQuery(f"Unsupported predicate node: {type(predicate).__name__}")
214
+ return handler(self, predicate, models)
@@ -0,0 +1,18 @@
1
+ """The store's backend identity row, owned by this adapter."""
2
+ from django.db.models.signals import post_migrate
3
+
4
+
5
+ def ensure_backend_identity(sender, using=None, **kwargs):
6
+ """`TransactionTestCase` flushes every table and re-emits `post_migrate`,
7
+ so the row has to be re-established rather than written once by a data
8
+ migration."""
9
+ from graphcore.persistence.django.models import BackendIdentityModel
10
+
11
+ BackendIdentityModel.objects.using(using).get_or_create(singleton=True)
12
+
13
+
14
+ def connect(app_config) -> None:
15
+ post_migrate.connect(
16
+ ensure_backend_identity, sender=app_config,
17
+ dispatch_uid='graphcore_backend_identity',
18
+ )
@@ -0,0 +1,252 @@
1
+ """Django storage models for the kernel's entity types.
2
+
3
+ Storage is a private decision below the serialization boundary: entities
4
+ never reference these classes, and nothing outside `persistence/django`
5
+ imports them except `graphcore/models.py` (Django's model discovery) and
6
+ the `public.persistence.django` facade.
7
+ """
8
+ from django.contrib.postgres.indexes import GinIndex
9
+ from django.db import models
10
+ from django.db.models import JSONField
11
+
12
+ from graphcore.types.entity_id import BACKEND_ID_LENGTH, new_backend_id
13
+
14
+
15
+ class BackendIdentityModel(models.Model):
16
+ """This deployment's immutable identity, minted once when the store is
17
+ initialised (`graphcore.apps` ensures it on `post_migrate`). `singleton`
18
+ is unique, so the store itself enforces that exactly one exists. Never
19
+ configuration: no setting, env var, or flag supplies it (see
20
+ docs/ENTITY_REFERENCE_TDD.md, Backend identity)."""
21
+ backend_id = models.CharField(
22
+ primary_key=True, max_length=BACKEND_ID_LENGTH, default=new_backend_id, editable=False,
23
+ )
24
+ singleton = models.BooleanField(default=True, unique=True)
25
+
26
+
27
+ class EntityModel(models.Model):
28
+ """
29
+ Base model for all entities in the system.
30
+ Stores core entity data and provides common functionality.
31
+ """
32
+ # `gc://<backend_id>/<local_id>`, minted by the entity. Opaque to storage:
33
+ # nothing here parses or routes it (docs/ENTITY_REFERENCE_TDD.md).
34
+ entity_id = models.CharField(max_length=96, primary_key=True, editable=False)
35
+ attributes = JSONField(default=dict, db_column='attributes')
36
+ # Single-parent containment (see docs/AUTHORIZATION_TECHNICAL_TDD.md,
37
+ # Containment): `parent_id` + `sibling_position` are the only persisted
38
+ # edge. `children_ids` on `Entity` is a derived, ordered projection over
39
+ # `parent_id` - never a stored column.
40
+ parent_id = models.CharField(max_length=255, null=True, blank=True, db_index=True)
41
+ sibling_position = models.FloatField(default=0.0)
42
+ # Every containing scope, root-first, maintained by the repository:
43
+ # `ancestor_ids(e) = ancestor_ids(parent) + [parent_id]`. Authorization
44
+ # is a predicate over this column rather than a join through a derived
45
+ # index (see docs/AUTHORIZATION_TECHNICAL_TDD.md, Inheritance).
46
+ ancestor_ids = JSONField(default=list)
47
+ # The forward reference projection, read with the row. Reverse lookup
48
+ # goes through `EntityReferenceModel`, never containment on this column.
49
+ reference_ids = JSONField(default=list)
50
+ created_at = models.DateTimeField(auto_now_add=True)
51
+ updated_at = models.DateTimeField(auto_now=True)
52
+ entity_type_id = models.CharField(max_length=100, db_index=True) # Stable identifier (e.g., 'graphcore.Document')
53
+ version = models.IntegerField(default=0, null=False) # Optimistic locking version
54
+
55
+ # Creator / ownership - UUID string of the User that created this entity
56
+ owner = models.CharField(max_length=200, null=True, blank=True)
57
+
58
+ class Meta:
59
+ # GIN indexes back the Postgres JSONB containment operators the
60
+ # compiler emits for `ContainsValue`/`ContainsAny`. Only meaningful
61
+ # on PostgreSQL; the accompanying migrations are no-ops elsewhere.
62
+ indexes = [
63
+ GinIndex(fields=['ancestor_ids'], name='entitymodel_ancestors_gin'),
64
+ models.Index(fields=['parent_id', 'sibling_position'], name='entitymodel_parent_pos_idx'),
65
+ ]
66
+
67
+
68
+ class EntityReferenceModel(models.Model):
69
+ """The reverse index over `EntityModel.reference_ids`: one row per
70
+ (target, source). The key order is what lets `referrers` walk a target's
71
+ sources in `entity_id` order and stop at the page limit. `target_id` is
72
+ not a foreign key - targets may be remote or deleted."""
73
+ pk = models.CompositePrimaryKey('target_id', 'source')
74
+ target_id = models.CharField(max_length=96)
75
+ source = models.ForeignKey(
76
+ EntityModel, on_delete=models.CASCADE, db_column='source_id', related_name='references',
77
+ )
78
+
79
+
80
+ class GrantModel(EntityModel):
81
+ """A persisted grant: `(subject_id, role_name)`, contained by the
82
+ resource it grants on (the inherited, indexed `parent_id` - a grant
83
+ has exactly one resource, so no denormalized column is needed).
84
+
85
+ `subject_id` and `role_name` are real columns, not attributes-bag JSON -
86
+ the two-tier convention that puts grant state beyond the generic
87
+ attribute strategies. See docs/AUTHORIZATION_TECHNICAL_TDD.md (Grant
88
+ storage).
89
+ """
90
+ subject_id = models.CharField(max_length=255)
91
+ role_name = models.CharField(max_length=100)
92
+
93
+ class Meta:
94
+ indexes = [
95
+ models.Index(fields=['subject_id'], name='grantmodel_subject_id_idx'),
96
+ ]
97
+
98
+ def __str__(self):
99
+ return f"GrantModel(entity_id={self.entity_id}, subject_id={self.subject_id}, role_name={self.role_name})"
100
+
101
+
102
+ class InviteModel(EntityModel):
103
+ """A pending invite, contained by the resource it invites to. Holds the
104
+ hash of the link secret, never the secret."""
105
+ role_name = models.CharField(max_length=100)
106
+ token_hash = models.CharField(max_length=64)
107
+ expires_at = models.FloatField(null=True, blank=True)
108
+ max_uses = models.IntegerField(default=1)
109
+ redeemed_by = JSONField(default=list)
110
+
111
+ def __str__(self):
112
+ return f"InviteModel(entity_id={self.entity_id}, role_name={self.role_name})"
113
+
114
+
115
+ class GroupModel(EntityModel):
116
+ """A pure subject: a name and a roster, nothing else."""
117
+ name = models.CharField(max_length=255, null=True, blank=True)
118
+ key = models.CharField(max_length=150, null=True, blank=True)
119
+ member_ids = JSONField(default=list)
120
+
121
+ class Meta:
122
+ indexes = [
123
+ GinIndex(fields=['member_ids'], name='group_member_ids_gin'),
124
+ ]
125
+ constraints = [
126
+ models.UniqueConstraint(
127
+ fields=['key'], name='uniq_group_key', condition=models.Q(key__isnull=False),
128
+ ),
129
+ ]
130
+
131
+ def __str__(self):
132
+ return f"GroupModel(entity_id={self.entity_id}, name={self.name})"
133
+
134
+
135
+ class ViewModel(EntityModel):
136
+ """Stored view state. `position_key` holds at most one view per sibling
137
+ scope, client, slot, and `renders`; a page is read by `address` and `client`."""
138
+ component = models.CharField(max_length=255, null=True, blank=True)
139
+ renders = models.CharField(max_length=255, null=True, blank=True, db_index=True)
140
+ client = models.CharField(max_length=255, null=True, blank=True)
141
+ slot = models.CharField(max_length=255, null=True, blank=True)
142
+ address = models.CharField(max_length=255, null=True, blank=True)
143
+ position_key = models.CharField(max_length=64, null=True, blank=True)
144
+ state = JSONField(default=dict)
145
+
146
+ class Meta:
147
+ indexes = [
148
+ models.Index(fields=['address', 'client'], name='view_address_client_idx'),
149
+ ]
150
+ constraints = [
151
+ models.UniqueConstraint(
152
+ fields=['position_key'], name='uniq_view_position_key',
153
+ condition=models.Q(position_key__isnull=False),
154
+ ),
155
+ ]
156
+
157
+ def __str__(self):
158
+ return f"ViewModel(entity_id={self.entity_id}, address={self.address}, slot={self.slot})"
159
+
160
+
161
+ class DeploymentModel(EntityModel):
162
+ """The single `Deployment`; `singleton` is unique, so concurrent
163
+ seeding cannot create a second one."""
164
+ singleton = models.BooleanField(default=True, unique=True, editable=False)
165
+ new_user_group_ids = models.JSONField(default=list)
166
+ new_user_roles = models.JSONField(default=list)
167
+
168
+
169
+ class UserModel(EntityModel):
170
+ """
171
+ Django model for User.
172
+ """
173
+ # The issuer's `preferred_username`, resynced on sign-in; for display.
174
+ username = models.CharField(max_length=150, null=True, blank=True)
175
+ # Assumes one external identity per user. If account linking is ever
176
+ # needed, these migrate cleanly to a `user 1—* identities` table.
177
+ issuer = models.CharField(max_length=255, null=True, blank=True)
178
+ subject = models.CharField(max_length=255, null=True, blank=True)
179
+
180
+ class Meta:
181
+ constraints = [
182
+ models.UniqueConstraint(
183
+ fields=['issuer', 'subject'],
184
+ name='uniq_user_iss_sub',
185
+ condition=models.Q(issuer__isnull=False, subject__isnull=False),
186
+ ),
187
+ ]
188
+
189
+ def __str__(self):
190
+ return f"UserModel(entity_id={self.entity_id}, issuer={self.issuer}, subject={self.subject})"
191
+
192
+
193
+ class ServiceAccountModel(EntityModel):
194
+ """
195
+ Django model for ServiceAccount.
196
+ """
197
+ app_id = models.CharField(max_length=100, null=True, blank=True)
198
+ client_name = models.CharField(max_length=100, null=True, blank=True)
199
+ client_id = models.CharField(max_length=255, null=True, blank=True)
200
+ issuer = models.CharField(max_length=255, null=True, blank=True)
201
+
202
+ class Meta:
203
+ constraints = [
204
+ models.UniqueConstraint(
205
+ fields=['client_id'],
206
+ name='uniq_service_account_client_id',
207
+ condition=models.Q(client_id__isnull=False),
208
+ ),
209
+ ]
210
+
211
+ def __str__(self):
212
+ return f"ServiceAccountModel(entity_id={self.entity_id}, client_id={self.client_id})"
213
+
214
+
215
+ class StrategyRequestModel(EntityModel):
216
+ """One run of a strategy and its outcome."""
217
+ strategy_name = models.CharField(max_length=255)
218
+ param_config = models.JSONField(default=dict)
219
+ target_entity_id = models.CharField(max_length=255, null=True, blank=True)
220
+ callbacks = models.JSONField(default=list)
221
+ callback_channel = models.CharField(max_length=255, null=True, blank=True)
222
+ client_request_id = models.CharField(max_length=255, null=True, blank=True)
223
+ status = models.CharField(max_length=16, default='pending')
224
+ attempt = models.IntegerField(default=0)
225
+ attempt_deadline = models.FloatField(null=True, blank=True)
226
+ ret_val = models.JSONField(default=dict)
227
+ error = models.TextField(null=True, blank=True)
228
+ error_code = models.CharField(max_length=64, null=True, blank=True)
229
+ error_details = models.JSONField(default=dict)
230
+ template_id = models.CharField(max_length=255, null=True, blank=True)
231
+
232
+ class Meta:
233
+ indexes = [
234
+ # The run reconciler's scan: running requests past their deadline.
235
+ models.Index(fields=['status', 'attempt_deadline'], name='request_status_deadline_idx'),
236
+ ]
237
+
238
+ def __str__(self):
239
+ return f"StrategyRequestModel(name={self.strategy_name}, entity_id={self.entity_id})"
240
+
241
+
242
+ class RequestTemplateModel(EntityModel):
243
+ """A request to make later, optionally on a schedule."""
244
+ strategy_name = models.CharField(max_length=255)
245
+ param_config = models.JSONField(default=dict)
246
+ target_entity_id = models.CharField(max_length=255, null=True, blank=True, db_index=True)
247
+ callbacks = models.JSONField(default=list)
248
+ cron = models.CharField(max_length=100, null=True, blank=True)
249
+ enabled = models.BooleanField(default=True)
250
+
251
+ def __str__(self):
252
+ return f"RequestTemplateModel(name={self.strategy_name}, entity_id={self.entity_id})"