dagster-cloud 1.8.2__py3-none-any.whl → 1.12.6__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 (108) hide show
  1. dagster_cloud/__init__.py +3 -3
  2. dagster_cloud/agent/__init__.py +4 -4
  3. dagster_cloud/agent/cli/__init__.py +56 -17
  4. dagster_cloud/agent/dagster_cloud_agent.py +360 -172
  5. dagster_cloud/agent/instrumentation/__init__.py +0 -0
  6. dagster_cloud/agent/instrumentation/constants.py +2 -0
  7. dagster_cloud/agent/instrumentation/run_launch.py +23 -0
  8. dagster_cloud/agent/instrumentation/schedule.py +34 -0
  9. dagster_cloud/agent/instrumentation/sensor.py +34 -0
  10. dagster_cloud/anomaly_detection/__init__.py +2 -2
  11. dagster_cloud/anomaly_detection/defs.py +17 -12
  12. dagster_cloud/anomaly_detection/types.py +3 -3
  13. dagster_cloud/api/dagster_cloud_api.py +209 -293
  14. dagster_cloud/auth/constants.py +21 -5
  15. dagster_cloud/batching/__init__.py +1 -0
  16. dagster_cloud/batching/batcher.py +210 -0
  17. dagster_cloud/dagster_insights/__init__.py +12 -6
  18. dagster_cloud/dagster_insights/bigquery/bigquery_utils.py +3 -2
  19. dagster_cloud/dagster_insights/bigquery/dbt_wrapper.py +39 -12
  20. dagster_cloud/dagster_insights/bigquery/insights_bigquery_resource.py +8 -6
  21. dagster_cloud/dagster_insights/insights_utils.py +18 -8
  22. dagster_cloud/dagster_insights/metrics_utils.py +12 -12
  23. dagster_cloud/dagster_insights/snowflake/dagster_snowflake_insights.py +5 -12
  24. dagster_cloud/dagster_insights/snowflake/dbt_wrapper.py +34 -8
  25. dagster_cloud/dagster_insights/snowflake/definitions.py +38 -12
  26. dagster_cloud/dagster_insights/snowflake/insights_snowflake_resource.py +11 -23
  27. dagster_cloud/definitions/__init__.py +0 -0
  28. dagster_cloud/definitions/job_selection.py +36 -0
  29. dagster_cloud/execution/cloud_run_launcher/k8s.py +1 -1
  30. dagster_cloud/execution/cloud_run_launcher/process.py +3 -3
  31. dagster_cloud/execution/monitoring/__init__.py +27 -33
  32. dagster_cloud/execution/utils/process.py +3 -3
  33. dagster_cloud/instance/__init__.py +125 -38
  34. dagster_cloud/instrumentation/__init__.py +32 -0
  35. dagster_cloud/metadata/source_code.py +13 -8
  36. dagster_cloud/metrics/__init__.py +0 -0
  37. dagster_cloud/metrics/tracer.py +59 -0
  38. dagster_cloud/opentelemetry/__init__.py +0 -0
  39. dagster_cloud/opentelemetry/config/__init__.py +73 -0
  40. dagster_cloud/opentelemetry/config/exporter.py +81 -0
  41. dagster_cloud/opentelemetry/config/log_record_processor.py +40 -0
  42. dagster_cloud/opentelemetry/config/logging_handler.py +14 -0
  43. dagster_cloud/opentelemetry/config/meter_provider.py +9 -0
  44. dagster_cloud/opentelemetry/config/metric_reader.py +39 -0
  45. dagster_cloud/opentelemetry/controller.py +319 -0
  46. dagster_cloud/opentelemetry/enum.py +58 -0
  47. dagster_cloud/opentelemetry/factories/__init__.py +1 -0
  48. dagster_cloud/opentelemetry/factories/logs.py +113 -0
  49. dagster_cloud/opentelemetry/factories/metrics.py +121 -0
  50. dagster_cloud/opentelemetry/metrics/__init__.py +0 -0
  51. dagster_cloud/opentelemetry/metrics/meter.py +140 -0
  52. dagster_cloud/opentelemetry/observers/__init__.py +0 -0
  53. dagster_cloud/opentelemetry/observers/dagster_exception_handler.py +40 -0
  54. dagster_cloud/opentelemetry/observers/execution_observer.py +178 -0
  55. dagster_cloud/pex/grpc/__generated__/multi_pex_api_pb2.pyi +175 -0
  56. dagster_cloud/pex/grpc/__init__.py +2 -2
  57. dagster_cloud/pex/grpc/client.py +4 -4
  58. dagster_cloud/pex/grpc/compile.py +2 -2
  59. dagster_cloud/pex/grpc/server/__init__.py +2 -2
  60. dagster_cloud/pex/grpc/server/cli/__init__.py +31 -19
  61. dagster_cloud/pex/grpc/server/manager.py +60 -42
  62. dagster_cloud/pex/grpc/server/registry.py +28 -21
  63. dagster_cloud/pex/grpc/server/server.py +23 -14
  64. dagster_cloud/pex/grpc/types.py +5 -5
  65. dagster_cloud/py.typed +0 -0
  66. dagster_cloud/secrets/__init__.py +1 -1
  67. dagster_cloud/secrets/loader.py +3 -3
  68. dagster_cloud/serverless/__init__.py +1 -1
  69. dagster_cloud/serverless/io_manager.py +36 -53
  70. dagster_cloud/storage/client.py +54 -17
  71. dagster_cloud/storage/compute_logs/__init__.py +3 -1
  72. dagster_cloud/storage/compute_logs/compute_log_manager.py +22 -17
  73. dagster_cloud/storage/defs_state/__init__.py +3 -0
  74. dagster_cloud/storage/defs_state/queries.py +15 -0
  75. dagster_cloud/storage/defs_state/storage.py +113 -0
  76. dagster_cloud/storage/event_logs/__init__.py +3 -1
  77. dagster_cloud/storage/event_logs/queries.py +102 -4
  78. dagster_cloud/storage/event_logs/storage.py +266 -73
  79. dagster_cloud/storage/event_logs/utils.py +88 -7
  80. dagster_cloud/storage/runs/__init__.py +1 -1
  81. dagster_cloud/storage/runs/queries.py +17 -2
  82. dagster_cloud/storage/runs/storage.py +88 -42
  83. dagster_cloud/storage/schedules/__init__.py +1 -1
  84. dagster_cloud/storage/schedules/storage.py +6 -8
  85. dagster_cloud/storage/tags.py +66 -1
  86. dagster_cloud/util/__init__.py +10 -12
  87. dagster_cloud/util/errors.py +49 -64
  88. dagster_cloud/version.py +1 -1
  89. dagster_cloud/workspace/config_schema/__init__.py +55 -13
  90. dagster_cloud/workspace/docker/__init__.py +76 -25
  91. dagster_cloud/workspace/docker/utils.py +1 -1
  92. dagster_cloud/workspace/ecs/__init__.py +1 -1
  93. dagster_cloud/workspace/ecs/client.py +51 -33
  94. dagster_cloud/workspace/ecs/launcher.py +76 -22
  95. dagster_cloud/workspace/ecs/run_launcher.py +3 -3
  96. dagster_cloud/workspace/ecs/utils.py +14 -5
  97. dagster_cloud/workspace/kubernetes/__init__.py +1 -1
  98. dagster_cloud/workspace/kubernetes/launcher.py +61 -29
  99. dagster_cloud/workspace/kubernetes/utils.py +34 -22
  100. dagster_cloud/workspace/user_code_launcher/__init__.py +5 -3
  101. dagster_cloud/workspace/user_code_launcher/process.py +16 -14
  102. dagster_cloud/workspace/user_code_launcher/user_code_launcher.py +552 -172
  103. dagster_cloud/workspace/user_code_launcher/utils.py +105 -1
  104. {dagster_cloud-1.8.2.dist-info → dagster_cloud-1.12.6.dist-info}/METADATA +48 -42
  105. dagster_cloud-1.12.6.dist-info/RECORD +134 -0
  106. {dagster_cloud-1.8.2.dist-info → dagster_cloud-1.12.6.dist-info}/WHEEL +1 -1
  107. dagster_cloud-1.8.2.dist-info/RECORD +0 -100
  108. {dagster_cloud-1.8.2.dist-info → dagster_cloud-1.12.6.dist-info}/top_level.txt +0 -0
File without changes
@@ -0,0 +1,2 @@
1
+ # Metrics name will start with this prefix
2
+ DAGSTER_CLOUD_AGENT_METRIC_PREFIX = "dagster_cloud"
@@ -0,0 +1,23 @@
1
+ import logging
2
+
3
+ from dagster import DagsterRun
4
+
5
+
6
+ def extract_run_attributes(deployment_name, run: DagsterRun) -> dict[str, str]:
7
+ attributes = {
8
+ "job": run.job_name or "unknown",
9
+ "repository": "unknown",
10
+ "location": "unknown",
11
+ "deployment": deployment_name,
12
+ }
13
+
14
+ try:
15
+ if run.remote_job_origin:
16
+ attributes["repository"] = (
17
+ run.remote_job_origin.repository_origin.repository_name or "unknown"
18
+ )
19
+ attributes["location"] = run.remote_job_origin.location_name or "unknown"
20
+ except Exception as e: # pylint: disable=broad-except
21
+ logging.warning("Failed to extract additional run attributes", exc_info=e)
22
+
23
+ return attributes
@@ -0,0 +1,34 @@
1
+ from dagster import deserialize_value
2
+ from dagster._core.definitions.schedule_definition import ScheduleExecutionData
3
+ from dagster._core.remote_representation.external_data import ScheduleExecutionErrorSnap
4
+
5
+ from dagster_cloud.opentelemetry.observers.execution_observer import ExecutionObserverInstruments
6
+
7
+
8
+ def inspect_schedule_result(
9
+ serialized_data_or_error: str,
10
+ instruments: ExecutionObserverInstruments,
11
+ attributes: dict[str, str],
12
+ ) -> str:
13
+ run_requests = []
14
+ status: str = "unknown"
15
+ try:
16
+ evaluation_execution_data = deserialize_value(serialized_data_or_error)
17
+ if isinstance(evaluation_execution_data, ScheduleExecutionData):
18
+ run_requests = evaluation_execution_data.run_requests or []
19
+ if run_requests:
20
+ status = "success"
21
+ else:
22
+ status = "skipped"
23
+ elif isinstance(evaluation_execution_data, ScheduleExecutionErrorSnap):
24
+ status = "error"
25
+ finally:
26
+ if run_requests:
27
+ meter = instruments.meter
28
+ counter = meter.get_counter(
29
+ name=f"{meter.name}.run_requests",
30
+ description="Number of run requests triggered by schedules",
31
+ )
32
+ counter.add(len(run_requests), attributes)
33
+
34
+ return status
@@ -0,0 +1,34 @@
1
+ from dagster import deserialize_value
2
+ from dagster._core.definitions.sensor_definition import SensorExecutionData
3
+ from dagster._core.remote_representation.external_data import SensorExecutionErrorSnap
4
+
5
+ from dagster_cloud.opentelemetry.observers.execution_observer import ExecutionObserverInstruments
6
+
7
+
8
+ def inspect_sensor_result(
9
+ serialized_data_or_error: str,
10
+ instruments: ExecutionObserverInstruments,
11
+ attributes: dict[str, str],
12
+ ) -> str:
13
+ run_requests = []
14
+ status: str = "unknown"
15
+ try:
16
+ evaluation_execution_data = deserialize_value(serialized_data_or_error)
17
+ if isinstance(evaluation_execution_data, SensorExecutionData):
18
+ run_requests = evaluation_execution_data.run_requests or []
19
+ if run_requests:
20
+ status = "success"
21
+ else:
22
+ status = "skipped"
23
+ elif isinstance(evaluation_execution_data, SensorExecutionErrorSnap):
24
+ status = "error"
25
+ finally:
26
+ if run_requests:
27
+ meter = instruments.meter
28
+ counter = meter.get_counter(
29
+ name=f"{meter.name}.run_requests",
30
+ description="Number of run requests triggered by sensors",
31
+ )
32
+ counter.add(len(run_requests), attributes)
33
+
34
+ return status
@@ -1,7 +1,7 @@
1
- from .defs import (
1
+ from dagster_cloud.anomaly_detection.defs import (
2
2
  build_anomaly_detection_freshness_checks as build_anomaly_detection_freshness_checks,
3
3
  )
4
- from .types import (
4
+ from dagster_cloud.anomaly_detection.types import (
5
5
  AnomalyDetectionModelParams as AnomalyDetectionModelParams,
6
6
  BetaFreshnessAnomalyDetectionParams as BetaFreshnessAnomalyDetectionParams,
7
7
  )
@@ -1,29 +1,33 @@
1
1
  import datetime
2
- from typing import Iterable, Optional, Sequence, Union, cast
2
+ from collections.abc import Iterable, Sequence
3
+ from typing import TYPE_CHECKING, Optional, Union, cast
3
4
 
4
5
  from dagster import (
5
6
  AssetCheckExecutionContext,
6
7
  MetadataValue,
7
8
  _check as check,
8
9
  )
9
- from dagster._core.definitions.asset_check_factories.freshness_checks.last_update import (
10
+ from dagster._core.definitions.asset_checks.asset_check_factories.freshness_checks.last_update import (
10
11
  construct_description,
11
12
  )
12
- from dagster._core.definitions.asset_check_factories.utils import (
13
+ from dagster._core.definitions.asset_checks.asset_check_factories.utils import (
13
14
  FRESH_UNTIL_METADATA_KEY,
14
15
  LAST_UPDATED_TIMESTAMP_METADATA_KEY,
15
16
  LOWER_BOUND_TIMESTAMP_METADATA_KEY,
16
17
  assets_to_keys,
17
18
  )
18
- from dagster._core.definitions.asset_check_result import AssetCheckResult
19
- from dagster._core.definitions.asset_check_spec import (
19
+ from dagster._core.definitions.asset_checks.asset_check_result import AssetCheckResult
20
+ from dagster._core.definitions.asset_checks.asset_check_spec import (
20
21
  AssetCheckKey,
21
22
  AssetCheckSeverity,
22
23
  AssetCheckSpec,
23
24
  )
24
- from dagster._core.definitions.asset_checks import AssetChecksDefinition
25
+ from dagster._core.definitions.asset_checks.asset_checks_definition import AssetChecksDefinition
25
26
  from dagster._core.definitions.asset_key import AssetKey
26
- from dagster._core.definitions.assets import AssetsDefinition, unique_id_from_asset_and_check_keys
27
+ from dagster._core.definitions.assets.definition.assets_definition import (
28
+ AssetsDefinition,
29
+ unique_id_from_asset_and_check_keys,
30
+ )
27
31
  from dagster._core.definitions.decorators.asset_check_decorator import multi_asset_check
28
32
  from dagster._core.definitions.events import CoercibleToAssetKey
29
33
  from dagster._core.definitions.source_asset import SourceAsset
@@ -35,15 +39,16 @@ from dagster_cloud_cli.core.graphql_client import (
35
39
  create_cloud_webserver_client,
36
40
  )
37
41
 
38
- from dagster_cloud import DagsterCloudAgentInstance
39
-
40
- from .mutation import ANOMALY_DETECTION_INFERENCE_MUTATION
41
- from .types import (
42
+ from dagster_cloud.anomaly_detection.mutation import ANOMALY_DETECTION_INFERENCE_MUTATION
43
+ from dagster_cloud.anomaly_detection.types import (
42
44
  AnomalyDetectionModelParams,
43
45
  BetaFreshnessAnomalyDetectionParams,
44
46
  FreshnessAnomalyDetectionResult,
45
47
  )
46
48
 
49
+ if TYPE_CHECKING:
50
+ from dagster_cloud import DagsterCloudAgentInstance
51
+
47
52
  DEFAULT_MODEL_PARAMS = BetaFreshnessAnomalyDetectionParams(sensitivity=0.1)
48
53
  MODEL_PARAMS_METADATA_KEY = "dagster/anomaly_detection_model_params"
49
54
  MODEL_VERSION_METADATA_KEY = "dagster/anomaly_detection_model_version"
@@ -88,7 +93,7 @@ def _build_check_for_assets(
88
93
  "Anomaly detection is only available for dagster cloud deployments."
89
94
  f"Instance type: {type(context.instance)}."
90
95
  )
91
- instance = cast(DagsterCloudAgentInstance, context.instance)
96
+ instance = cast("DagsterCloudAgentInstance", context.instance)
92
97
  with create_cloud_webserver_client(
93
98
  instance.dagit_url[:-1]
94
99
  if instance.dagit_url.endswith("/")
@@ -1,6 +1,6 @@
1
1
  from abc import abstractproperty
2
2
  from enum import Enum
3
- from typing import Any, Dict
3
+ from typing import Any
4
4
 
5
5
  from dagster import DagsterError
6
6
  from pydantic import BaseModel
@@ -60,7 +60,7 @@ class AnomalyDetectionModelParams(BaseModel):
60
60
  raise NotImplementedError("Subclasses must implement this method")
61
61
 
62
62
  @abstractproperty
63
- def as_metadata(self) -> Dict[str, Any]:
63
+ def as_metadata(self) -> dict[str, Any]:
64
64
  raise NotImplementedError("Subclasses must implement this method")
65
65
 
66
66
 
@@ -72,7 +72,7 @@ class BetaFreshnessAnomalyDetectionParams(AnomalyDetectionModelParams):
72
72
  return AnomalyDetectionModelVersion.FRESHNESS_BETA
73
73
 
74
74
  @property
75
- def as_metadata(self) -> Dict[str, Any]:
75
+ def as_metadata(self) -> dict[str, Any]:
76
76
  return {
77
77
  "sensitivity": self.sensitivity,
78
78
  }