dagster-cloud 1.12.6__py3-none-any.whl → 1.12.8__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.
@@ -505,6 +505,16 @@ class DagsterCloudAgent:
505
505
  if self._instance.user_code_launcher.agent_metrics_enabled
506
506
  else {}
507
507
  },
508
+ {
509
+ "allowed_full_deployment_locations": self._instance.allowed_full_deployment_locations
510
+ if self._instance.allowed_full_deployment_locations
511
+ else {},
512
+ },
513
+ {
514
+ "allowed_branch_deployment_locations": self._instance.allowed_branch_deployment_locations
515
+ if self._instance.allowed_branch_deployment_locations
516
+ else [],
517
+ },
508
518
  ),
509
519
  run_worker_statuses=run_worker_statuses_dict[deployment_name],
510
520
  code_server_heartbeats=code_server_heartbeats_dict.get(deployment_name, []),
@@ -599,6 +609,23 @@ class DagsterCloudAgent:
599
609
 
600
610
  for entry in entries:
601
611
  location_name = entry["locationName"]
612
+
613
+ # Skip locations not in the allowed list if configured
614
+ if not self._instance.is_location_allowed(
615
+ deployment_name, location_name, is_branch_deployment
616
+ ):
617
+ deployment_type = (
618
+ "for branch deployments"
619
+ if is_branch_deployment
620
+ else f"in deployment {deployment_name}"
621
+ )
622
+ self._logger.error(
623
+ f"Skipping location {location_name} {deployment_type} - not in allowed locations list. "
624
+ "Either configure this location's dagster_cloud.yaml file to use a different queue, "
625
+ "or redeploy this agent with this location in the list of allowed locations."
626
+ )
627
+ continue
628
+
602
629
  code_location_deploy_data = deserialize_value(
603
630
  entry["serializedDeploymentMetadata"], CodeLocationDeployData
604
631
  )
@@ -730,6 +757,22 @@ class DagsterCloudAgent:
730
757
  for entry in entries:
731
758
  location_name = entry["locationName"]
732
759
 
760
+ # Skip locations not in the allowed list if configured
761
+ if not self._instance.is_location_allowed(
762
+ deployment_name, location_name, is_branch_deployment
763
+ ):
764
+ deployment_type = (
765
+ "for branch deployments"
766
+ if is_branch_deployment
767
+ else f"in deployment {deployment_name}"
768
+ )
769
+ self._logger.error(
770
+ f"Skipping location {location_name} {deployment_type} - not in allowed locations list. "
771
+ "Either configure this location's dagster_cloud.yaml file to use a different queue, "
772
+ "or redeploy this agent with this location in the list of allowed locations."
773
+ )
774
+ continue
775
+
733
776
  location_key = (deployment_name, location_name)
734
777
 
735
778
  all_locations.add(location_key)
@@ -833,6 +876,22 @@ class DagsterCloudAgent:
833
876
  code_location_origin = self._get_location_origin_from_request(request)
834
877
  location_name = code_location_origin.location_name if code_location_origin else None
835
878
 
879
+ # Validate that the location is in the allowed list if configured
880
+ if location_name and not self._instance.is_location_allowed(
881
+ deployment_name, location_name, is_branch_deployment
882
+ ):
883
+ deployment_type = (
884
+ "for branch deployments"
885
+ if is_branch_deployment
886
+ else f"in deployment '{deployment_name}'"
887
+ )
888
+ raise Exception(
889
+ f"Agent is not allowed to serve location '{location_name}' {deployment_type}. "
890
+ f"Location is not in the alloweupd locations list configured for this agent. "
891
+ "Either configure this location's dagster_cloud.yaml file to use a different queue, "
892
+ "or redeploy this agent with this location in the list of allowed locations."
893
+ )
894
+
836
895
  if api_name == DagsterCloudApi.PING_LOCATION:
837
896
  # Do nothing - this request only exists to bump TTL for the location
838
897
  return DagsterCloudApiSuccess()
@@ -1233,7 +1292,9 @@ class DagsterCloudAgent:
1233
1292
  (deployment_name, location_name, is_branch_deployment)
1234
1293
  ] = time.time()
1235
1294
 
1236
- if not user_code_launcher.has_grpc_endpoint(deployment_name, location_name):
1295
+ if self._instance.is_location_allowed(
1296
+ deployment_name, location_name, is_branch_deployment
1297
+ ) and not user_code_launcher.has_grpc_endpoint(deployment_name, location_name):
1237
1298
  # Next completed periodic workspace update will make the location up to date
1238
1299
  # - keep this in the queue until then
1239
1300
  invalid_requests.append(json_request)
@@ -10,6 +10,7 @@ import yaml
10
10
  from dagster import (
11
11
  Array,
12
12
  Field,
13
+ Map,
13
14
  String,
14
15
  _check as check,
15
16
  )
@@ -79,6 +80,8 @@ class DagsterCloudAgentInstance(DagsterCloudInstance):
79
80
  agent_replicas=None,
80
81
  isolated_agents=None,
81
82
  agent_queues=None,
83
+ allowed_full_deployment_locations=None,
84
+ allowed_branch_deployment_locations=None,
82
85
  agent_metrics=None,
83
86
  opentelemetry=None,
84
87
  **kwargs,
@@ -145,6 +148,13 @@ class DagsterCloudAgentInstance(DagsterCloudInstance):
145
148
  )
146
149
  self.agent_queues_config = AgentQueuesConfig(**processed_agent_queues_config) # pyright: ignore[reportCallIssue]
147
150
 
151
+ self._allowed_full_deployment_locations: Optional[dict[str, list[str]]] = (
152
+ allowed_full_deployment_locations
153
+ )
154
+ self._allowed_branch_deployment_locations: Optional[list[str]] = (
155
+ allowed_branch_deployment_locations
156
+ )
157
+
148
158
  self._opentelemetry_config: Optional[Mapping[str, Any]] = self._get_processed_config(
149
159
  "opentelemetry", opentelemetry, opentelemetry_config_schema()
150
160
  )
@@ -462,6 +472,32 @@ class DagsterCloudAgentInstance(DagsterCloudInstance):
462
472
  def instance_uuid(self) -> str:
463
473
  return self._instance_uuid
464
474
 
475
+ @property
476
+ def allowed_full_deployment_locations(self) -> Optional[dict[str, list[str]]]:
477
+ return self._allowed_full_deployment_locations
478
+
479
+ @property
480
+ def allowed_branch_deployment_locations(self) -> Optional[list[str]]:
481
+ return self._allowed_branch_deployment_locations
482
+
483
+ def is_location_allowed(
484
+ self, deployment_name: str, location_name: str, is_branch_deployment: bool
485
+ ) -> bool:
486
+ """Check if a location should be allowed based on the allowed locations configuration."""
487
+ if is_branch_deployment:
488
+ # For branch deployments, check the branch deployment locations list
489
+ if self._allowed_branch_deployment_locations is not None:
490
+ return location_name in self._allowed_branch_deployment_locations
491
+ else:
492
+ # For full deployments, check the deployment-specific locations map
493
+ if self._allowed_full_deployment_locations is not None:
494
+ allowed_locations = self._allowed_full_deployment_locations.get(deployment_name)
495
+ if allowed_locations is not None:
496
+ return location_name in allowed_locations
497
+
498
+ # If no restrictions are configured, allow all locations
499
+ return True
500
+
465
501
  @property
466
502
  def agent_display_name(self) -> str:
467
503
  if self.dagster_cloud_api_agent_label:
@@ -536,6 +572,16 @@ instance_class:
536
572
  cls._isolated_agents_config_schema(), is_required=False
537
573
  ), # deprecated in favor of isolated_agents
538
574
  "agent_queues": Field(cls._agent_queues_config_schema(), is_required=False),
575
+ "allowed_full_deployment_locations": Field(
576
+ Map(String, Array(String)),
577
+ is_required=False,
578
+ description="Mapping of full deployment names to allowed location names",
579
+ ),
580
+ "allowed_branch_deployment_locations": Field(
581
+ Array(String),
582
+ is_required=False,
583
+ description="List of allowed location names for branch deployments",
584
+ ),
539
585
  "opentelemetry": Field(
540
586
  opentelemetry_config_schema(), is_required=False, default_value={"enabled": False}
541
587
  ),
dagster_cloud/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.12.6"
1
+ __version__ = "1.12.8"
@@ -46,7 +46,14 @@ def get_instance_ref_for_user_code(instance_ref: InstanceRef) -> InstanceRef:
46
46
  if custom_instance_class_data:
47
47
  config_dict = custom_instance_class_data.config_dict
48
48
  new_config_dict = {
49
- key: val for key, val in config_dict.items() if key not in {"agent_queues"}
49
+ key: val
50
+ for key, val in config_dict.items()
51
+ if key
52
+ not in {
53
+ "agent_queues",
54
+ "allowed_full_deployment_locations",
55
+ "allowed_branch_deployment_locations",
56
+ }
50
57
  }
51
58
 
52
59
  user_code_launcher_config = config_dict.get("user_code_launcher", {}).get("config")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dagster-cloud
3
- Version: 1.12.6
3
+ Version: 1.12.8
4
4
  Author-email: Elementl <support@elementl.com>
5
5
  License: Apache-2.0
6
6
  Project-URL: Homepage, https://dagster.io/cloud
@@ -28,9 +28,9 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
28
28
  Classifier: Operating System :: OS Independent
29
29
  Requires-Python: <3.14,>=3.9
30
30
  Description-Content-Type: text/markdown
31
- Requires-Dist: dagster==1.12.6
32
- Requires-Dist: dagster-shared==1.12.6
33
- Requires-Dist: dagster-cloud-cli==1.12.6
31
+ Requires-Dist: dagster==1.12.8
32
+ Requires-Dist: dagster-shared==1.12.8
33
+ Requires-Dist: dagster-cloud-cli==1.12.8
34
34
  Requires-Dist: opentelemetry-api<2,>=1.27.0
35
35
  Requires-Dist: opentelemetry-sdk<2,>=1.27.0
36
36
  Requires-Dist: opentelemetry-exporter-otlp-proto-grpc<2,>=1.27.0
@@ -65,12 +65,12 @@ Provides-Extra: insights
65
65
  Requires-Dist: pyarrow; extra == "insights"
66
66
  Provides-Extra: docker
67
67
  Requires-Dist: docker; extra == "docker"
68
- Requires-Dist: dagster-docker==0.28.6; extra == "docker"
68
+ Requires-Dist: dagster-docker==0.28.8; extra == "docker"
69
69
  Provides-Extra: kubernetes
70
70
  Requires-Dist: kubernetes; extra == "kubernetes"
71
- Requires-Dist: dagster-k8s==0.28.6; extra == "kubernetes"
71
+ Requires-Dist: dagster-k8s==0.28.8; extra == "kubernetes"
72
72
  Provides-Extra: ecs
73
- Requires-Dist: dagster-aws==0.28.6; extra == "ecs"
73
+ Requires-Dist: dagster-aws==0.28.8; extra == "ecs"
74
74
  Requires-Dist: boto3; extra == "ecs"
75
75
  Provides-Extra: sandbox
76
76
  Requires-Dist: supervisor; extra == "sandbox"
@@ -1,9 +1,9 @@
1
1
  dagster_cloud/__init__.py,sha256=zyM9bqyJFxtEClv_5X4VRldrj0UniKgZzEl0pPJJ_Ts,355
2
2
  dagster_cloud/constants.py,sha256=CPAqXJ99SWGMviksdIA2A9894FEvHChNk8UcP4TluYM,455
3
3
  dagster_cloud/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- dagster_cloud/version.py,sha256=K-O_Zmi1DuK_mEBcDOT_b5zNp9ONlW-73xBIaMAX9Fo,23
4
+ dagster_cloud/version.py,sha256=MukaistZHiQ_HvCd7oJvFM6KoAwAzuUNKkDHr_pCzwk,23
5
5
  dagster_cloud/agent/__init__.py,sha256=_erVyIrxuHUiyNerwX8vNZcKZN8NAloTEkPq8vPZ3MI,811
6
- dagster_cloud/agent/dagster_cloud_agent.py,sha256=bNMPSJBURWYbwAPhTbYq34o5qxPrqVWI2JA9b6vKHiw,58341
6
+ dagster_cloud/agent/dagster_cloud_agent.py,sha256=3W4wdz61LEGHYiG0cY8oDCm8oVgCalM5QTU8AZJjCgA,61566
7
7
  dagster_cloud/agent/queries.py,sha256=iI84GQ1Zxt5ryo6M1ELIaIae-gwUY14QPPMUeiFK97o,1837
8
8
  dagster_cloud/agent/cli/__init__.py,sha256=rGbeQJ2Ap95wPYQuk5XbyHAfP9cs-XPUSmuVM_k278k,9084
9
9
  dagster_cloud/agent/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -46,7 +46,7 @@ dagster_cloud/execution/cloud_run_launcher/process.py,sha256=eYxvzcaJbqYKjHcXMUU
46
46
  dagster_cloud/execution/monitoring/__init__.py,sha256=2_o2UjeEPvfSpnOb0zky3ZQs-G9VHABAXzjvfMnAh8A,17782
47
47
  dagster_cloud/execution/utils/__init__.py,sha256=EfU-tK5-ScZYLF_zmWqUgIrmLsb9DDHWFN-CSg3BSXY,254
48
48
  dagster_cloud/execution/utils/process.py,sha256=Er6FKMdlGBjpOHDEIkukZf4-TiZ3Xi_iqurfxkOozGM,911
49
- dagster_cloud/instance/__init__.py,sha256=ecxGScVMeqQJqegEUOzMA-LRkovHSB5LgkL4zcFyz8c,26135
49
+ dagster_cloud/instance/__init__.py,sha256=v_9zjhcf-nXYpK9KoOBax4T1vb8rp_05U1bAi3Tgot0,28228
50
50
  dagster_cloud/instrumentation/__init__.py,sha256=OKaT4qkwQNmCFdKveVrgB7JIo5sZD1F1rutQKdozK_4,886
51
51
  dagster_cloud/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
52
  dagster_cloud/metadata/source_code.py,sha256=yCUfD6V-wR2s4AUrmVpX_Dd7Gln7SYbtpuEpAH71J1I,5952
@@ -127,8 +127,8 @@ dagster_cloud/workspace/kubernetes/utils.py,sha256=2PrxCXew-KZmluVyW9jC9z_kuPcch
127
127
  dagster_cloud/workspace/user_code_launcher/__init__.py,sha256=E-Izs69AHPAXD9pqd3UH46l4uKxM4Lbz7y2G4KeWzEQ,880
128
128
  dagster_cloud/workspace/user_code_launcher/process.py,sha256=6TwjlXZzBlzyQEvmGzuVAUgxe_vCye0Q3aYkPPDAshs,14315
129
129
  dagster_cloud/workspace/user_code_launcher/user_code_launcher.py,sha256=BWkm4stk35HrFGydB5Cp61v-OI3z1eTZsFUec1hpGSI,103700
130
- dagster_cloud/workspace/user_code_launcher/utils.py,sha256=t8Epee9MrXtRhWL-b_3avXxgMGrjLScUNWtBUUGpMCg,5285
131
- dagster_cloud-1.12.6.dist-info/METADATA,sha256=jbYPAjaRt_dKqF0q-f8HksyqFny7utaQk0VlQMeX8-M,6582
132
- dagster_cloud-1.12.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
133
- dagster_cloud-1.12.6.dist-info/top_level.txt,sha256=2hMt-U33jyCgnywNrDB9Ih0EpaVmiO6dFkYcJ7Iwx4I,14
134
- dagster_cloud-1.12.6.dist-info/RECORD,,
130
+ dagster_cloud/workspace/user_code_launcher/utils.py,sha256=173BNpm1ylt6euwLSnK1kpvp_cVqKJxpitetuWnXBI0,5460
131
+ dagster_cloud-1.12.8.dist-info/METADATA,sha256=cZ3pt_nweBDoJ5EDMoN_aQDc5bvyKoQhaiQuacWXxqc,6582
132
+ dagster_cloud-1.12.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
133
+ dagster_cloud-1.12.8.dist-info/top_level.txt,sha256=2hMt-U33jyCgnywNrDB9Ih0EpaVmiO6dFkYcJ7Iwx4I,14
134
+ dagster_cloud-1.12.8.dist-info/RECORD,,