infrahub-server 1.4.13__py3-none-any.whl → 1.5.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 (222) hide show
  1. infrahub/actions/tasks.py +208 -16
  2. infrahub/api/artifact.py +3 -0
  3. infrahub/api/diff/diff.py +1 -1
  4. infrahub/api/internal.py +2 -0
  5. infrahub/api/query.py +2 -0
  6. infrahub/api/schema.py +27 -3
  7. infrahub/auth.py +5 -5
  8. infrahub/cli/__init__.py +2 -0
  9. infrahub/cli/db.py +160 -157
  10. infrahub/cli/dev.py +118 -0
  11. infrahub/cli/upgrade.py +56 -9
  12. infrahub/computed_attribute/tasks.py +19 -7
  13. infrahub/config.py +7 -2
  14. infrahub/core/attribute.py +35 -24
  15. infrahub/core/branch/enums.py +1 -1
  16. infrahub/core/branch/models.py +9 -5
  17. infrahub/core/branch/needs_rebase_status.py +11 -0
  18. infrahub/core/branch/tasks.py +72 -10
  19. infrahub/core/changelog/models.py +2 -10
  20. infrahub/core/constants/__init__.py +4 -0
  21. infrahub/core/constants/infrahubkind.py +1 -0
  22. infrahub/core/convert_object_type/object_conversion.py +201 -0
  23. infrahub/core/convert_object_type/repository_conversion.py +89 -0
  24. infrahub/core/convert_object_type/schema_mapping.py +27 -3
  25. infrahub/core/diff/model/path.py +4 -0
  26. infrahub/core/diff/payload_builder.py +1 -1
  27. infrahub/core/diff/query/artifact.py +1 -0
  28. infrahub/core/diff/query/field_summary.py +1 -0
  29. infrahub/core/graph/__init__.py +1 -1
  30. infrahub/core/initialization.py +7 -4
  31. infrahub/core/manager.py +3 -81
  32. infrahub/core/migrations/__init__.py +3 -0
  33. infrahub/core/migrations/exceptions.py +4 -0
  34. infrahub/core/migrations/graph/__init__.py +11 -10
  35. infrahub/core/migrations/graph/load_schema_branch.py +21 -0
  36. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +1 -1
  37. infrahub/core/migrations/graph/m037_index_attr_vals.py +11 -30
  38. infrahub/core/migrations/graph/m039_ipam_reconcile.py +9 -7
  39. infrahub/core/migrations/graph/m042_profile_attrs_in_db.py +147 -0
  40. infrahub/core/migrations/graph/m043_create_hfid_display_label_in_db.py +164 -0
  41. infrahub/core/migrations/graph/m044_backfill_hfid_display_label_in_db.py +864 -0
  42. infrahub/core/migrations/query/__init__.py +7 -8
  43. infrahub/core/migrations/query/attribute_add.py +8 -6
  44. infrahub/core/migrations/query/attribute_remove.py +134 -0
  45. infrahub/core/migrations/runner.py +54 -0
  46. infrahub/core/migrations/schema/attribute_kind_update.py +9 -3
  47. infrahub/core/migrations/schema/attribute_supports_profile.py +90 -0
  48. infrahub/core/migrations/schema/node_attribute_add.py +26 -5
  49. infrahub/core/migrations/schema/node_attribute_remove.py +13 -109
  50. infrahub/core/migrations/schema/node_kind_update.py +2 -1
  51. infrahub/core/migrations/schema/node_remove.py +2 -1
  52. infrahub/core/migrations/schema/placeholder_dummy.py +3 -2
  53. infrahub/core/migrations/shared.py +66 -19
  54. infrahub/core/models.py +2 -2
  55. infrahub/core/node/__init__.py +207 -54
  56. infrahub/core/node/create.py +53 -49
  57. infrahub/core/node/lock_utils.py +124 -0
  58. infrahub/core/node/node_property_attribute.py +230 -0
  59. infrahub/core/node/resource_manager/ip_address_pool.py +2 -1
  60. infrahub/core/node/resource_manager/ip_prefix_pool.py +2 -1
  61. infrahub/core/node/resource_manager/number_pool.py +2 -1
  62. infrahub/core/node/standard.py +1 -1
  63. infrahub/core/property.py +11 -0
  64. infrahub/core/protocols.py +8 -1
  65. infrahub/core/query/attribute.py +82 -15
  66. infrahub/core/query/ipam.py +16 -4
  67. infrahub/core/query/node.py +66 -188
  68. infrahub/core/query/relationship.py +44 -26
  69. infrahub/core/query/subquery.py +0 -8
  70. infrahub/core/relationship/model.py +69 -24
  71. infrahub/core/schema/__init__.py +56 -0
  72. infrahub/core/schema/attribute_schema.py +4 -2
  73. infrahub/core/schema/basenode_schema.py +42 -2
  74. infrahub/core/schema/definitions/core/__init__.py +2 -0
  75. infrahub/core/schema/definitions/core/check.py +1 -1
  76. infrahub/core/schema/definitions/core/generator.py +2 -0
  77. infrahub/core/schema/definitions/core/group.py +16 -2
  78. infrahub/core/schema/definitions/core/repository.py +7 -0
  79. infrahub/core/schema/definitions/core/transform.py +1 -1
  80. infrahub/core/schema/definitions/internal.py +12 -3
  81. infrahub/core/schema/generated/attribute_schema.py +2 -2
  82. infrahub/core/schema/generated/base_node_schema.py +6 -1
  83. infrahub/core/schema/manager.py +3 -0
  84. infrahub/core/schema/node_schema.py +1 -0
  85. infrahub/core/schema/relationship_schema.py +0 -1
  86. infrahub/core/schema/schema_branch.py +295 -10
  87. infrahub/core/schema/schema_branch_display.py +135 -0
  88. infrahub/core/schema/schema_branch_hfid.py +120 -0
  89. infrahub/core/validators/aggregated_checker.py +1 -1
  90. infrahub/database/graph.py +21 -0
  91. infrahub/display_labels/__init__.py +0 -0
  92. infrahub/display_labels/gather.py +48 -0
  93. infrahub/display_labels/models.py +240 -0
  94. infrahub/display_labels/tasks.py +192 -0
  95. infrahub/display_labels/triggers.py +22 -0
  96. infrahub/events/branch_action.py +27 -1
  97. infrahub/events/group_action.py +1 -1
  98. infrahub/events/node_action.py +1 -1
  99. infrahub/generators/constants.py +7 -0
  100. infrahub/generators/models.py +38 -12
  101. infrahub/generators/tasks.py +34 -16
  102. infrahub/git/base.py +38 -1
  103. infrahub/git/integrator.py +22 -14
  104. infrahub/graphql/api/dependencies.py +2 -4
  105. infrahub/graphql/api/endpoints.py +16 -6
  106. infrahub/graphql/app.py +2 -4
  107. infrahub/graphql/initialization.py +2 -3
  108. infrahub/graphql/manager.py +213 -137
  109. infrahub/graphql/middleware.py +12 -0
  110. infrahub/graphql/mutations/branch.py +16 -0
  111. infrahub/graphql/mutations/computed_attribute.py +110 -3
  112. infrahub/graphql/mutations/convert_object_type.py +44 -13
  113. infrahub/graphql/mutations/display_label.py +118 -0
  114. infrahub/graphql/mutations/generator.py +25 -7
  115. infrahub/graphql/mutations/hfid.py +125 -0
  116. infrahub/graphql/mutations/ipam.py +73 -41
  117. infrahub/graphql/mutations/main.py +61 -178
  118. infrahub/graphql/mutations/profile.py +195 -0
  119. infrahub/graphql/mutations/proposed_change.py +8 -1
  120. infrahub/graphql/mutations/relationship.py +2 -2
  121. infrahub/graphql/mutations/repository.py +22 -83
  122. infrahub/graphql/mutations/resource_manager.py +2 -2
  123. infrahub/graphql/mutations/webhook.py +1 -1
  124. infrahub/graphql/queries/resource_manager.py +1 -1
  125. infrahub/graphql/registry.py +173 -0
  126. infrahub/graphql/resolvers/resolver.py +2 -0
  127. infrahub/graphql/schema.py +8 -1
  128. infrahub/graphql/schema_sort.py +170 -0
  129. infrahub/graphql/types/branch.py +4 -1
  130. infrahub/graphql/types/enums.py +3 -0
  131. infrahub/groups/tasks.py +1 -1
  132. infrahub/hfid/__init__.py +0 -0
  133. infrahub/hfid/gather.py +48 -0
  134. infrahub/hfid/models.py +240 -0
  135. infrahub/hfid/tasks.py +191 -0
  136. infrahub/hfid/triggers.py +22 -0
  137. infrahub/lock.py +119 -42
  138. infrahub/locks/__init__.py +0 -0
  139. infrahub/locks/tasks.py +37 -0
  140. infrahub/patch/plan_writer.py +2 -2
  141. infrahub/permissions/constants.py +2 -0
  142. infrahub/profiles/__init__.py +0 -0
  143. infrahub/profiles/node_applier.py +101 -0
  144. infrahub/profiles/queries/__init__.py +0 -0
  145. infrahub/profiles/queries/get_profile_data.py +98 -0
  146. infrahub/profiles/tasks.py +63 -0
  147. infrahub/proposed_change/tasks.py +24 -5
  148. infrahub/repositories/__init__.py +0 -0
  149. infrahub/repositories/create_repository.py +113 -0
  150. infrahub/server.py +9 -1
  151. infrahub/services/__init__.py +8 -5
  152. infrahub/services/adapters/workflow/worker.py +5 -2
  153. infrahub/task_manager/event.py +5 -0
  154. infrahub/task_manager/models.py +7 -0
  155. infrahub/tasks/registry.py +6 -4
  156. infrahub/trigger/catalogue.py +4 -0
  157. infrahub/trigger/models.py +2 -0
  158. infrahub/trigger/setup.py +13 -4
  159. infrahub/trigger/tasks.py +6 -0
  160. infrahub/webhook/models.py +1 -1
  161. infrahub/workers/dependencies.py +3 -1
  162. infrahub/workers/infrahub_async.py +5 -1
  163. infrahub/workflows/catalogue.py +118 -3
  164. infrahub/workflows/initialization.py +21 -0
  165. infrahub/workflows/models.py +17 -2
  166. infrahub_sdk/branch.py +17 -8
  167. infrahub_sdk/checks.py +1 -1
  168. infrahub_sdk/client.py +376 -95
  169. infrahub_sdk/config.py +29 -2
  170. infrahub_sdk/convert_object_type.py +61 -0
  171. infrahub_sdk/ctl/branch.py +3 -0
  172. infrahub_sdk/ctl/check.py +2 -3
  173. infrahub_sdk/ctl/cli_commands.py +20 -12
  174. infrahub_sdk/ctl/config.py +8 -2
  175. infrahub_sdk/ctl/generator.py +6 -3
  176. infrahub_sdk/ctl/graphql.py +184 -0
  177. infrahub_sdk/ctl/repository.py +39 -1
  178. infrahub_sdk/ctl/schema.py +40 -10
  179. infrahub_sdk/ctl/task.py +110 -0
  180. infrahub_sdk/ctl/utils.py +4 -0
  181. infrahub_sdk/ctl/validate.py +5 -3
  182. infrahub_sdk/diff.py +4 -5
  183. infrahub_sdk/exceptions.py +2 -0
  184. infrahub_sdk/generator.py +7 -1
  185. infrahub_sdk/graphql/__init__.py +12 -0
  186. infrahub_sdk/graphql/constants.py +1 -0
  187. infrahub_sdk/graphql/plugin.py +85 -0
  188. infrahub_sdk/graphql/query.py +77 -0
  189. infrahub_sdk/{graphql.py → graphql/renderers.py} +88 -75
  190. infrahub_sdk/graphql/utils.py +40 -0
  191. infrahub_sdk/node/attribute.py +2 -0
  192. infrahub_sdk/node/node.py +28 -20
  193. infrahub_sdk/node/relationship.py +1 -3
  194. infrahub_sdk/playback.py +1 -2
  195. infrahub_sdk/protocols.py +54 -6
  196. infrahub_sdk/pytest_plugin/plugin.py +7 -4
  197. infrahub_sdk/pytest_plugin/utils.py +40 -0
  198. infrahub_sdk/repository.py +1 -2
  199. infrahub_sdk/schema/__init__.py +70 -4
  200. infrahub_sdk/schema/main.py +1 -0
  201. infrahub_sdk/schema/repository.py +8 -0
  202. infrahub_sdk/spec/models.py +7 -0
  203. infrahub_sdk/spec/object.py +54 -6
  204. infrahub_sdk/spec/processors/__init__.py +0 -0
  205. infrahub_sdk/spec/processors/data_processor.py +10 -0
  206. infrahub_sdk/spec/processors/factory.py +34 -0
  207. infrahub_sdk/spec/processors/range_expand_processor.py +56 -0
  208. infrahub_sdk/spec/range_expansion.py +118 -0
  209. infrahub_sdk/task/models.py +6 -4
  210. infrahub_sdk/timestamp.py +18 -6
  211. infrahub_sdk/transforms.py +1 -1
  212. {infrahub_server-1.4.13.dist-info → infrahub_server-1.5.0.dist-info}/METADATA +9 -10
  213. {infrahub_server-1.4.13.dist-info → infrahub_server-1.5.0.dist-info}/RECORD +221 -165
  214. infrahub_testcontainers/container.py +114 -2
  215. infrahub_testcontainers/docker-compose-cluster.test.yml +5 -0
  216. infrahub_testcontainers/docker-compose.test.yml +5 -0
  217. infrahub_testcontainers/models.py +2 -2
  218. infrahub_testcontainers/performance_test.py +4 -4
  219. infrahub/core/convert_object_type/conversion.py +0 -134
  220. {infrahub_server-1.4.13.dist-info → infrahub_server-1.5.0.dist-info}/LICENSE.txt +0 -0
  221. {infrahub_server-1.4.13.dist-info → infrahub_server-1.5.0.dist-info}/WHEEL +0 -0
  222. {infrahub_server-1.4.13.dist-info → infrahub_server-1.5.0.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,7 @@
1
1
  import random
2
2
 
3
3
  from fast_depends import Depends, inject
4
+ from prefect.client.schemas.objects import ConcurrencyLimitStrategy
4
5
 
5
6
  from .constants import WorkflowTag, WorkflowType
6
7
  from .models import WorkerPoolDefinition, WorkflowDefinition
@@ -17,14 +18,14 @@ ACTION_ADD_NODE_TO_GROUP = WorkflowDefinition(
17
18
 
18
19
  ACTION_RUN_GENERATOR = WorkflowDefinition(
19
20
  name="action-run-generator",
20
- type=WorkflowType.CORE,
21
+ type=WorkflowType.INTERNAL,
21
22
  module="infrahub.actions.tasks",
22
23
  function="run_generator",
23
24
  )
24
25
 
25
26
  ACTION_RUN_GENERATOR_GROUP_EVENT = WorkflowDefinition(
26
27
  name="action-run-generator-group-event",
27
- type=WorkflowType.CORE,
28
+ type=WorkflowType.INTERNAL,
28
29
  module="infrahub.actions.tasks",
29
30
  function="run_generator_group_event",
30
31
  )
@@ -83,7 +84,7 @@ TRIGGER_ARTIFACT_DEFINITION_GENERATE = WorkflowDefinition(
83
84
 
84
85
  TRIGGER_GENERATOR_DEFINITION_RUN = WorkflowDefinition(
85
86
  name="generator-definition-run",
86
- type=WorkflowType.CORE,
87
+ type=WorkflowType.INTERNAL,
87
88
  module="infrahub.generators.tasks",
88
89
  function="run_generator_definition",
89
90
  tags=[WorkflowTag.DATABASE_CHANGE],
@@ -179,6 +180,8 @@ GIT_REPOSITORIES_SYNC = WorkflowDefinition(
179
180
  cron="* * * * *",
180
181
  module="infrahub.git.tasks",
181
182
  function="sync_remote_repositories",
183
+ concurrency_limit=1,
184
+ concurrency_limit_strategy=ConcurrencyLimitStrategy.CANCEL_NEW,
182
185
  )
183
186
 
184
187
  GIT_REPOSITORIES_CREATE_BRANCH = WorkflowDefinition(
@@ -227,6 +230,13 @@ BRANCH_REBASE = WorkflowDefinition(
227
230
  function="rebase_branch",
228
231
  tags=[WorkflowTag.DATABASE_CHANGE],
229
232
  )
233
+ BRANCH_MIGRATE = WorkflowDefinition(
234
+ name="branch-migrate",
235
+ type=WorkflowType.CORE,
236
+ module="infrahub.core.branch.tasks",
237
+ function="migrate_branch",
238
+ tags=[WorkflowTag.DATABASE_CHANGE],
239
+ )
230
240
 
231
241
  BRANCH_CREATE = WorkflowDefinition(
232
242
  name="create-branch",
@@ -320,6 +330,62 @@ COMPUTED_ATTRIBUTE_JINJA2_UPDATE_VALUE = WorkflowDefinition(
320
330
  tags=[WorkflowTag.DATABASE_CHANGE],
321
331
  )
322
332
 
333
+ DISPLAY_LABELS_PROCESS_JINJA2 = WorkflowDefinition(
334
+ name="display-label-process-jinja2",
335
+ type=WorkflowType.CORE,
336
+ module="infrahub.display_labels.tasks",
337
+ function="process_display_label",
338
+ tags=[WorkflowTag.DATABASE_CHANGE],
339
+ )
340
+
341
+ DISPLAY_LABEL_JINJA2_UPDATE_VALUE = WorkflowDefinition(
342
+ name="display-label-jinja2-update-value",
343
+ type=WorkflowType.CORE,
344
+ module="infrahub.display_labels.tasks",
345
+ function="display_label_jinja2_update_value",
346
+ tags=[WorkflowTag.DATABASE_CHANGE],
347
+ )
348
+
349
+ HFID_PROCESS = WorkflowDefinition(
350
+ name="hfid-process",
351
+ type=WorkflowType.CORE,
352
+ module="infrahub.hfid.tasks",
353
+ function="process_hfid",
354
+ tags=[WorkflowTag.DATABASE_CHANGE],
355
+ )
356
+
357
+ HFID_SETUP = WorkflowDefinition(
358
+ name="hfid-setup",
359
+ type=WorkflowType.CORE,
360
+ module="infrahub.hfid.tasks",
361
+ function="hfid_setup",
362
+ )
363
+
364
+
365
+ HFID_UPDATE_VALUE = WorkflowDefinition(
366
+ name="hfid-update-value",
367
+ type=WorkflowType.CORE,
368
+ module="infrahub.hfid.tasks",
369
+ function="hfid_update_value",
370
+ tags=[WorkflowTag.DATABASE_CHANGE],
371
+ )
372
+
373
+ TRIGGER_UPDATE_DISPLAY_LABELS = WorkflowDefinition(
374
+ name="trigger-update-display-labels",
375
+ type=WorkflowType.CORE,
376
+ module="infrahub.display_labels.tasks",
377
+ function="trigger_update_display_labels",
378
+ tags=[WorkflowTag.DATABASE_CHANGE],
379
+ )
380
+
381
+ TRIGGER_UPDATE_HFID = WorkflowDefinition(
382
+ name="trigger-update-hfid",
383
+ type=WorkflowType.CORE,
384
+ module="infrahub.hfid.tasks",
385
+ function="trigger_update_hfid",
386
+ tags=[WorkflowTag.DATABASE_CHANGE],
387
+ )
388
+
323
389
  TRIGGER_UPDATE_JINJA_COMPUTED_ATTRIBUTES = WorkflowDefinition(
324
390
  name="trigger_update_jinja2_computed_attributes",
325
391
  type=WorkflowType.CORE,
@@ -356,6 +422,14 @@ COMPUTED_ATTRIBUTE_PROCESS_TRANSFORM = WorkflowDefinition(
356
422
  tags=[WorkflowTag.DATABASE_CHANGE],
357
423
  )
358
424
 
425
+ DISPLAY_LABELS_SETUP_JINJA2 = WorkflowDefinition(
426
+ name="display-labels-setup-jinja2",
427
+ type=WorkflowType.CORE,
428
+ module="infrahub.display_labels.tasks",
429
+ function="display_labels_setup_jinja2",
430
+ )
431
+
432
+
359
433
  QUERY_COMPUTED_ATTRIBUTE_TRANSFORM_TARGETS = WorkflowDefinition(
360
434
  name="query-computed-attribute-transform-targets",
361
435
  type=WorkflowType.CORE,
@@ -531,6 +605,35 @@ VALIDATE_SCHEMA_NUMBER_POOLS = WorkflowDefinition(
531
605
  )
532
606
 
533
607
 
608
+ PROFILE_REFRESH_MULTIPLE = WorkflowDefinition(
609
+ name="objects-profiles-refresh-multiple",
610
+ type=WorkflowType.CORE,
611
+ module="infrahub.profiles.tasks",
612
+ function="objects_profiles_refresh_multiple",
613
+ tags=[WorkflowTag.DATABASE_CHANGE],
614
+ )
615
+
616
+
617
+ PROFILE_REFRESH = WorkflowDefinition(
618
+ name="object-profiles-refresh",
619
+ type=WorkflowType.CORE,
620
+ module="infrahub.profiles.tasks",
621
+ function="object_profiles_refresh",
622
+ tags=[WorkflowTag.DATABASE_CHANGE],
623
+ )
624
+
625
+
626
+ CLEAN_UP_DEADLOCKS = WorkflowDefinition(
627
+ name="clean-up-deadlocks",
628
+ type=WorkflowType.INTERNAL,
629
+ cron="* * * * *",
630
+ module="infrahub.locks.tasks",
631
+ function="clean_up_deadlocks",
632
+ concurrency_limit=1,
633
+ concurrency_limit_strategy=ConcurrencyLimitStrategy.CANCEL_NEW,
634
+ )
635
+
636
+
534
637
  WORKER_POOLS = [INFRAHUB_WORKER_POOL]
535
638
 
536
639
  WORKFLOWS = [
@@ -545,8 +648,10 @@ WORKFLOWS = [
545
648
  BRANCH_MERGED,
546
649
  BRANCH_MERGE_MUTATION,
547
650
  BRANCH_MERGE_POST_PROCESS,
651
+ BRANCH_MIGRATE,
548
652
  BRANCH_REBASE,
549
653
  BRANCH_VALIDATE,
654
+ CLEAN_UP_DEADLOCKS,
550
655
  COMPUTED_ATTRIBUTE_JINJA2_UPDATE_VALUE,
551
656
  COMPUTED_ATTRIBUTE_PROCESS_JINJA2,
552
657
  COMPUTED_ATTRIBUTE_PROCESS_TRANSFORM,
@@ -556,6 +661,9 @@ WORKFLOWS = [
556
661
  DIFF_REFRESH,
557
662
  DIFF_REFRESH_ALL,
558
663
  DIFF_UPDATE,
664
+ DISPLAY_LABELS_PROCESS_JINJA2,
665
+ DISPLAY_LABELS_SETUP_JINJA2,
666
+ DISPLAY_LABEL_JINJA2_UPDATE_VALUE,
559
667
  GIT_REPOSITORIES_CHECK_ARTIFACT_CREATE,
560
668
  GIT_REPOSITORIES_CREATE_BRANCH,
561
669
  GIT_REPOSITORIES_DIFF_NAMES_ONLY,
@@ -571,7 +679,12 @@ WORKFLOWS = [
571
679
  GIT_REPOSITORY_USER_CHECKS_TRIGGER,
572
680
  GIT_REPOSITORY_USER_CHECK_RUN,
573
681
  GRAPHQL_QUERY_GROUP_UPDATE,
682
+ HFID_PROCESS,
683
+ HFID_SETUP,
684
+ HFID_UPDATE_VALUE,
574
685
  IPAM_RECONCILIATION,
686
+ PROFILE_REFRESH,
687
+ PROFILE_REFRESH_MULTIPLE,
575
688
  PROPOSED_CHANGE_MERGE,
576
689
  QUERY_COMPUTED_ATTRIBUTE_TRANSFORM_TARGETS,
577
690
  REMOVE_ADD_NODE_FROM_GROUP,
@@ -597,6 +710,8 @@ WORKFLOWS = [
597
710
  TRIGGER_ARTIFACT_DEFINITION_GENERATE,
598
711
  TRIGGER_CONFIGURE_ALL,
599
712
  TRIGGER_GENERATOR_DEFINITION_RUN,
713
+ TRIGGER_UPDATE_DISPLAY_LABELS,
714
+ TRIGGER_UPDATE_HFID,
600
715
  TRIGGER_UPDATE_JINJA_COMPUTED_ATTRIBUTES,
601
716
  TRIGGER_UPDATE_PYTHON_COMPUTED_ATTRIBUTES,
602
717
  VALIDATE_SCHEMA_NUMBER_POOLS,
@@ -7,6 +7,8 @@ from prefect.exceptions import ObjectAlreadyExists
7
7
  from prefect.logging import get_run_logger
8
8
 
9
9
  from infrahub import config
10
+ from infrahub.display_labels.gather import gather_trigger_display_labels_jinja2
11
+ from infrahub.hfid.gather import gather_trigger_hfid
10
12
  from infrahub.trigger.catalogue import builtin_triggers
11
13
  from infrahub.trigger.models import TriggerType
12
14
  from infrahub.trigger.setup import setup_triggers
@@ -74,3 +76,22 @@ async def setup_task_manager() -> None:
74
76
  await setup_triggers(
75
77
  client=client, triggers=builtin_triggers, trigger_type=TriggerType.BUILTIN, force_update=True
76
78
  )
79
+
80
+
81
+ @flow(name="task-manager-identifiers", flow_run_name="Setup Task Manager Display Labels and HFID")
82
+ async def setup_task_manager_identifiers() -> None:
83
+ async with get_client(sync_client=False) as client:
84
+ display_label_triggers = await gather_trigger_display_labels_jinja2()
85
+ await setup_triggers(
86
+ client=client,
87
+ triggers=display_label_triggers,
88
+ trigger_type=TriggerType.DISPLAY_LABEL_JINJA2,
89
+ force_update=True,
90
+ ) # type: ignore[misc]
91
+ hfid_triggers = await gather_trigger_hfid()
92
+ await setup_triggers(
93
+ client=client,
94
+ triggers=hfid_triggers,
95
+ trigger_type=TriggerType.HUMAN_FRIENDLY_ID,
96
+ force_update=True,
97
+ ) # type: ignore[misc]
@@ -6,7 +6,7 @@ from uuid import UUID
6
6
  from prefect import Flow
7
7
  from prefect.client.orchestration import PrefectClient
8
8
  from prefect.client.schemas.actions import DeploymentScheduleCreate
9
- from prefect.client.schemas.objects import FlowRun
9
+ from prefect.client.schemas.objects import ConcurrencyLimitStrategy, FlowRun
10
10
  from prefect.client.schemas.schedules import CronSchedule
11
11
  from pydantic import BaseModel, Field
12
12
  from typing_extensions import Self
@@ -48,6 +48,14 @@ class WorkflowDefinition(BaseModel):
48
48
  function: str
49
49
  cron: str | None = None
50
50
  tags: list[WorkflowTag] = Field(default_factory=list)
51
+ concurrency_limit: int | None = Field(
52
+ default=None,
53
+ description="The concurrency limit for the deployment.",
54
+ )
55
+ concurrency_limit_strategy: ConcurrencyLimitStrategy | None = Field(
56
+ default=None,
57
+ description="The concurrency options for the deployment.",
58
+ )
51
59
 
52
60
  @property
53
61
  def entrypoint(self) -> str:
@@ -60,7 +68,14 @@ class WorkflowDefinition(BaseModel):
60
68
  return f"{self.name}/{self.name}"
61
69
 
62
70
  def to_deployment(self) -> dict[str, Any]:
63
- payload: dict[str, Any] = {"name": self.name, "entrypoint": self.entrypoint, "tags": self.get_tags()}
71
+ payload: dict[str, Any] = {
72
+ "name": self.name,
73
+ "entrypoint": self.entrypoint,
74
+ "tags": self.get_tags(),
75
+ "concurrency_limit": self.concurrency_limit,
76
+ }
77
+ if self.concurrency_limit_strategy:
78
+ payload["concurrency_options"] = {"collision_strategy": self.concurrency_limit_strategy}
64
79
  if self.type == WorkflowType.CORE:
65
80
  payload["version"] = __version__
66
81
  if self.cron:
infrahub_sdk/branch.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import warnings
4
+ from enum import Enum
4
5
  from typing import TYPE_CHECKING, Any, Literal, overload
5
6
  from urllib.parse import urlencode
6
7
 
@@ -14,6 +15,13 @@ if TYPE_CHECKING:
14
15
  from .client import InfrahubClient, InfrahubClientSync
15
16
 
16
17
 
18
+ class BranchStatus(str, Enum):
19
+ OPEN = "OPEN"
20
+ NEED_REBASE = "NEED_REBASE"
21
+ NEED_UPGRADE_REBASE = "NEED_UPGRADE_REBASE"
22
+ DELETING = "DELETING"
23
+
24
+
17
25
  class BranchData(BaseModel):
18
26
  id: str
19
27
  name: str
@@ -21,6 +29,8 @@ class BranchData(BaseModel):
21
29
  sync_with_git: bool
22
30
  is_default: bool
23
31
  has_schema_changes: bool
32
+ graph_version: int | None = None
33
+ status: BranchStatus = BranchStatus.OPEN
24
34
  origin_branch: str | None = None
25
35
  branched_from: str
26
36
 
@@ -34,6 +44,8 @@ BRANCH_DATA = {
34
44
  "is_default": None,
35
45
  "sync_with_git": None,
36
46
  "has_schema_changes": None,
47
+ "graph_version": None,
48
+ "status": None,
37
49
  }
38
50
 
39
51
  BRANCH_DATA_FILTER = {"@filters": {"name": "$branch_name"}}
@@ -188,9 +200,7 @@ class InfrahubBranchManager(InfraHubBranchManagerBase):
188
200
  query = Query(name="GetAllBranch", query=QUERY_ALL_BRANCHES_DATA)
189
201
  data = await self.client.execute_graphql(query=query.render(), tracker="query-branch-all")
190
202
 
191
- branches = {branch["name"]: BranchData(**branch) for branch in data["Branch"]}
192
-
193
- return branches
203
+ return {branch["name"]: BranchData(**branch) for branch in data["Branch"]}
194
204
 
195
205
  async def get(self, branch_name: str) -> BranchData:
196
206
  query = Query(name="GetBranch", query=QUERY_ONE_BRANCH_DATA, variables={"branch_name": str})
@@ -230,9 +240,7 @@ class InfrahubBranchManagerSync(InfraHubBranchManagerBase):
230
240
  query = Query(name="GetAllBranch", query=QUERY_ALL_BRANCHES_DATA)
231
241
  data = self.client.execute_graphql(query=query.render(), tracker="query-branch-all")
232
242
 
233
- branches = {branch["name"]: BranchData(**branch) for branch in data["Branch"]}
234
-
235
- return branches
243
+ return {branch["name"]: BranchData(**branch) for branch in data["Branch"]}
236
244
 
237
245
  def get(self, branch_name: str) -> BranchData:
238
246
  query = Query(name="GetBranch", query=QUERY_ONE_BRANCH_DATA, variables={"branch_name": str})
@@ -292,13 +300,14 @@ class InfrahubBranchManagerSync(InfraHubBranchManagerBase):
292
300
  },
293
301
  }
294
302
 
295
- query = Mutation(mutation="BranchCreate", input_data=input_data, query=MUTATION_QUERY_DATA)
303
+ mutation_query = MUTATION_QUERY_TASK if background_execution else MUTATION_QUERY_DATA
304
+ query = Mutation(mutation="BranchCreate", input_data=input_data, query=mutation_query)
296
305
  response = self.client.execute_graphql(query=query.render(), tracker="mutation-branch-create")
297
306
 
298
307
  # Make sure server version is recent enough to support background execution, as previously
299
308
  # using background_execution=True had no effect.
300
309
  if background_execution and "task" in response["BranchCreate"]:
301
- return BranchData(**response["BranchCreate"]["task"]["id"])
310
+ return response["BranchCreate"]["task"]["id"]
302
311
  return BranchData(**response["BranchCreate"]["object"])
303
312
 
304
313
  def delete(self, branch_name: str) -> bool:
infrahub_sdk/checks.py CHANGED
@@ -33,7 +33,7 @@ class InfrahubCheckInitializer(BaseModel):
33
33
  class InfrahubCheck:
34
34
  name: str | None = None
35
35
  query: str = ""
36
- timeout: int = 10
36
+ timeout: int = 60
37
37
 
38
38
  def __init__(
39
39
  self,