repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
dagster
python_modules/dagster-test/dagster_test/toys/asset_checks.py
.py
import random import time from dagster import ( AssetCheckKey, AssetCheckResult, AssetCheckSeverity, AssetCheckSpec, AssetExecutionContext, AssetKey, AssetOut, AssetSelection, In, MaterializeResult, MetadataValue, Nothing, Output, asset, asset_check, buil...
514
14,189
dagster
python_modules/dagster-test/dagster_test/toys/partition_config.py
.py
from dagster import job, op from dagster._core.definitions.partitions.partitioned_config import static_partitioned_config @static_partitioned_config(["a", "b", "c"]) def partconf(partition): return {"ops": {"op1": {"letter": partition}}} @op(config_schema={"letter": str}) def op1(): ... @job(config=partconf) ...
17
363
dagster
python_modules/dagster-test/dagster_test/toys/log_asset.py
.py
from dagster import Array, Output, graph, op @op(config_schema={"asset_key": Array(str), "ops": str}) def read_materialization(context): asset_key = context.op_config["asset_key"] from_graph = context.op_config["graph"] context.log.info(f"Found materialization for asset key {asset_key} in {from_graph}") ...
20
510
dagster
python_modules/dagster-test/dagster_test/toys/many_partitions_ranged_backfill.py
.py
"""An asset with a large number of partitions (hourly over 1 years = 8760 partitions) and a single-run backfill policy. When backfilled, will generate a large number of `store_event` or `store_event_batch` calls, depending on if batching is enabled. Use a DummyIOManager to avoid unnecessary writes. """ from dagster im...
32
1,046
dagster
python_modules/dagster-test/dagster_test/toys/basic_assets.py
.py
from dagster import AssetSelection, MetadataValue, asset, define_asset_job @asset(group_name="basic_assets") def basic_asset_1(): ... @asset(group_name="basic_assets") def basic_asset_2(basic_asset_1): ... @asset(group_name="basic_assets") def basic_asset_3(basic_asset_1): ... @asset(group_name="basic_assets") ...
25
581
dagster
python_modules/dagster-test/dagster_test/toys/graph_backed_assets.py
.py
from dagster import graph_asset, op @op def hello(): return "hello" @op def world(hello): return hello + "world" @graph_asset def graph_backed_asset(): return world(hello())
17
192
dagster
python_modules/dagster-test/dagster_test/toys/log_spew.py
.py
import time from dagster import In, Out, Output, graph, op def nonce_op(name, n_inputs, n_outputs): """Creates an op with the given number of (meaningless) inputs and outputs. Config controls the behavior of the nonce op. """ @op( name=name, ins={f"input_{i}": In() for i in range(n_...
60
1,845
dagster
python_modules/dagster-test/dagster_test/toys/unreliable.py
.py
from random import random from dagster import Field, graph, op DEFAULT_EXCEPTION_RATE = 0.3 @op def unreliable_start(): return 1 @op(config_schema={"rate": Field(float, is_required=False, default_value=DEFAULT_EXCEPTION_RATE)}) def unreliable_op(context, num): if random() < context.op_config["rate"]: ...
37
893
dagster
python_modules/dagster-test/dagster_test/toys/hammer.py
.py
import random import time from dagster import Field, In, Out, Output, graph, op @op( ins={"chase_duration": In(int)}, out=Out(int), config_schema={ "chase_size": Field( int, default_value=100000, is_required=False, description="How big should the po...
69
1,788
dagster
python_modules/dagster-test/dagster_test/toys/asset_health.py
.py
from datetime import timedelta import dagster as dg from dagster._core.definitions.freshness import FreshnessPolicy from dagster._time import get_current_timestamp def should_fail(logger): now = get_current_timestamp() logger.info(f"Current timestamp: {int(now)}") if int(now) % 2 == 0: return Fal...
277
7,147
dagster
python_modules/dagster-test/dagster_test/toys/conditional_assets.py
.py
import random from dagster import Output, asset @asset(output_required=False) def may_not_materialize(context): random.seed() rand_num = random.randint(1, 10) context.log.info( f"Random number is {rand_num}. Asset will {'not' if rand_num >= 5 else ''} materialize." ) if rand_num < 5: ...
20
443
dagster
python_modules/dagster-test/dagster_test/toys/metadata.py
.py
from dagster import MetadataValue, job, op @op def my_op(): return "so cool!" @job( metadata={ "owner": "data team", "link": MetadataValue.url(url="https://dagster.io"), }, ) def with_metadata(): my_op()
17
240
dagster
python_modules/dagster-test/dagster_test/toys/long_asset_keys.py
.py
from dagster import AssetIn, asset key_prefix1 = ["s3", "superdomain_1", "subdomain_1", "subsubdomain_1"] @asset(key_prefix=key_prefix1) def asset1(): pass @asset( key_prefix=["s3", "superdomain_2", "subdomain_2", "subsubdomain_2"], ins={"asset1": AssetIn(key_prefix=key_prefix1)}, ) def asset2(asset1):...
17
347
dagster
python_modules/dagster-test/dagster_test/toys/multi_inputs_outputs.py
.py
from dagster import Int, Out, Output, graph, op @op( out={"out_1": Out(Int), "out_2": Out(Int)}, ) def first_op(_context): yield Output(1, "out_1") yield Output(2, "out_2") @op( out={ "out_1": Out(Int), "out_2": Out(Int), "out_3": Out(Int), "out_4": Out(Int), ...
59
1,526
dagster
python_modules/dagster-test/dagster_test/toys/repo.py
.py
import warnings from typing import TYPE_CHECKING, cast from dagster import BetaWarning, PreviewWarning from dagster._time import get_current_timestamp # squelch preview and beta warnings since we often include preview and beta things in toys for development warnings.simplefilter("ignore", category=PreviewWarning) war...
262
8,029
dagster
python_modules/dagster-test/dagster_test/toys/freshness.py
.py
from datetime import timedelta import dagster as dg from dagster._core.definitions.freshness import FreshnessPolicy @dg.asset(freshness_policy=FreshnessPolicy.time_window(fail_window=timedelta(minutes=60))) def asset_with_time_window_freshness_60m(): return 1 @dg.asset(freshness_policy=FreshnessPolicy.time_win...
88
2,273
dagster
python_modules/dagster-test/dagster_test/toys/freshness_checks.py
.py
import math import random from datetime import timedelta from dagster import ( AssetExecutionContext, MetadataValue, ObserveResult, ScheduleDefinition, TimestampMetadataValue, _check as check, asset, build_last_update_freshness_checks, build_sensor_for_freshness_checks, define_a...
114
3,566
dagster
python_modules/dagster-test/dagster_test/toys/longitudinal.py
.py
import math import time from datetime import datetime from random import random from dagster import AssetMaterialization, In, Nothing, Out, fs_io_manager, graph, op from dagster._utils.partitions import DEFAULT_DATE_FORMAT TRAFFIC_CONSTANTS = { 0: 1, 1: 0.92, 2: 0.88, 3: 0.86, 4: 0.81, 5: 0.69...
143
3,909
dagster
python_modules/dagster-test/dagster_test/toys/dynamic.py
.py
from dagster import DynamicOut, Field, graph, op from dagster._core.definitions.events import DynamicOutput @op def multiply_by_two(context, y): context.log.info("echo_again is returning " + str(y * 2)) return y * 2 @op(config_schema={"fail_on_first_try": Field(bool, default_value=False)}) def multiply_inpu...
44
1,065
dagster
python_modules/dagster-test/dagster_test/toys/data_versions.py
.py
import datetime from dagster import ( AssetOut, DataVersion, Output, SourceAsset, asset, multi_asset, observable_source_asset, ) @observable_source_asset def observable_different_version(): return DataVersion(str(datetime.datetime.now())) @observable_source_asset def observable_same...
73
1,503
dagster
python_modules/dagster-test/dagster_test/toys/cross_repo_assets.py
.py
from dagster import AssetKey, SourceAsset, asset @asset def upstream_asset(): return 5 upstream_repo_assets = [upstream_asset] source_assets = [ SourceAsset(AssetKey("upstream_asset")), SourceAsset(AssetKey("always_source_asset")), ] @asset def downstream_asset1(upstream_asset, always_source_asset): ...
31
627
dagster
python_modules/dagster-test/dagster_test/toys/log_file.py
.py
import os from dagster import AssetKey, AssetMaterialization, Field, MetadataValue, Output, graph, op @op( config_schema={ "filename": Field(str, is_required=True), "directory": Field(str, is_required=True), } ) def read_file(context): relative_filename = context.op_config["filename"] ...
41
1,194
dagster
python_modules/dagster-test/dagster_test/toys/seed_asset_failure_events.py
.py
from dagster import AssetKey, job, op from dagster._core.definitions.asset_checks.asset_check_evaluation import ( AssetCheckEvaluation, AssetCheckEvaluationTargetMaterializationData, ) from dagster._core.definitions.asset_checks.asset_check_spec import AssetCheckSeverity from dagster._core.definitions.events im...
156
5,337
dagster
python_modules/dagster-test/dagster_test/toys/sleepy.py
.py
from time import sleep from dagster import Field, Out, Output, graph, op from dagster._core.execution.context.compute import OpExecutionContext @op def sleeper(context, units: list[int]) -> int: tot = 0 for sec in units: context.log.info(f"Sleeping for {sec} seconds") sleep(sec) tot +...
74
1,698
dagster
python_modules/dagster-test/dagster_test/toys/error_monster.py
.py
from dagster import ( Failure, Field, In, Int, IOManager, Out, ResourceDefinition, RetryRequested, String, graph, io_manager, op, ) from dagster._core.definitions.executor_definition import in_process_executor from dagster._utils import segfault class ExampleException(E...
213
6,160
dagster
python_modules/dagster-test/dagster_test/toys/input_managers.py
.py
import os import numpy as np import pandas as pd from dagster import Field, In, IOManager, Noneable, graph, io_manager, op class PandasCsvIOManager(IOManager): def __init__(self, base_dir=None): self.base_dir = os.getenv("DAGSTER_HOME") if base_dir is None else base_dir def _get_path(self, output_co...
113
3,451
dagster
python_modules/dagster-test/dagster_test/toys/composition.py
.py
from dagster import Float, In, Int, List, Out, graph, op @op(out=Out(Int)) def emit_one(): return 1 @op(ins={"numbers": In(List[Int])}, out=Out(Int)) def add(numbers): return sum(numbers) @op(ins={"num": In(Float)}, out=Out(Float)) def div_two(num): return num / 2 @graph def emit_two(): return a...
45
740
dagster
python_modules/dagster-test/dagster_test/toys/log_s3.py
.py
from dagster import AssetKey, AssetMaterialization, Field, MetadataValue, Output, graph, op @op( config_schema={ "bucket": Field(str, is_required=True), "s3_key": Field(str, is_required=True), } ) def read_s3_key(context): s3_key = context.op_config["s3_key"] bucket = context.op_config...
28
711
dagster
python_modules/dagster-test/dagster_test/toys/notebooks.py
.py
from dagster import job, op try: from dagstermill.factory import define_dagstermill_op hello_world_notebook_op = define_dagstermill_op("hello_world_notebook_op", "hello_world.ipynb") except ImportError: # We don't include dagstermill in our setup.py for dagster_test to keep it lean so we # can't rely ...
21
563
dagster
python_modules/dagster-test/dagster_test/toys/sensors.py
.py
import os from dagster import ( AssetKey, DefaultSensorStatus, RunFailureSensorContext, RunRequest, SkipReason, _check as check, asset_sensor, run_failure_sensor, sensor, ) from dagster_slack import make_slack_on_run_failure_sensor from slack_sdk.web.client import WebClient from da...
187
6,139
dagster
python_modules/dagster-test/dagster_test/toys/alert_helpers.py
.py
import random import time from typing import Any import dagster as dg """ Repo of assets and ops that are useful for testing alerts """ def generate_random_schema(column_names: list[str]): column_types = ["string", "int", "timestamp", "float"] tags = [{"priority": "high"}, {"team": "marketing"}, {"region": ...
55
1,423
dagster
python_modules/dagster-test/dagster_test/toys/big_honkin_asset_graph.py
.py
import random import time from dagster import ( AssetKey, AssetMaterialization, AssetsDefinition, OpExecutionContext, asset, job, op, ) N_ASSETS = 1000 def generate_big_honkin_assets() -> list[AssetsDefinition]: random.seed(5438790) assets = [] for i in range(N_ASSETS): ...
61
1,312
dagster
python_modules/dagster-test/dagster_test/toys/module_with_groups.py
.py
from dagster import Definitions, asset assets = [] for i in range(4): @asset(name=f"a_asset_{i}", group_name="my_asset_group_1") def a_asset(): pass @asset( name=f"b_asset_{i}", group_name="my_asset_group_2", non_argument_deps={f"a_asset_{i}"}, ) def b_asset(): ...
30
572
dagster
python_modules/dagster-test/dagster_test/toys/nothing_input.py
.py
from dagster import In, Nothing, job, op @op def op_with_nothing_output() -> None: ... @op(ins={"in1": In(Nothing)}) def op_with_nothing_input() -> None: ... @job def nothing_job(): op_with_nothing_input(op_with_nothing_output())
15
240
dagster
python_modules/dagster-test/dagster_test/toys/retries.py
.py
import time from dagster import RetryRequested, graph, op @op def echo(x): return x @op(config_schema={"max_retries": int, "delay": float, "work_on_attempt": int}) def retry_op(context): time.sleep(0.1) if (context.retry_number + 1) >= context.op_config["work_on_attempt"]: return "success" ...
41
799
dagster
python_modules/dagster-test/dagster_test/toys/software_defined_assets.py
.py
import time from dagster import AssetKey, IOManager, IOManagerDefinition, SourceAsset, asset, with_resources sfo_q2_weather_sample = SourceAsset(key=AssetKey("sfo_q2_weather_sample")) class DataFrame: pass class DummyIOManager(IOManager): def handle_output(self, context, obj: DataFrame): assert co...
59
1,572
dagster
python_modules/dagster-test/dagster_test/toys/simple_config.py
.py
from dagster import job, op @op( config_schema={"num": int}, ) def requires_config(context): return context.op_config @job( tags={ "dagster-k8s/config": { "container_config": { "resources": { "requests": {"cpu": "3"}, }, ...
24
389
dagster
python_modules/dagster-test/dagster_test/toys/table_metadata.py
.py
"""An asset with associated `TableMetadataValue` and `TableSchemaMetadataValue. The asset does nothing. It exists just to have a place to attach the TableMetadataValue. """ from dagster import MetadataValue, asset from dagster._core.definitions.metadata.table import ( TableColumn, TableColumnConstraints, ...
46
1,481
dagster
python_modules/dagster-test/dagster_test/toys/asset_sensors.py
.py
import time from dagster import ( AssetKey, AssetOut, RunRequest, SkipReason, asset, job, multi_asset, multi_asset_sensor, op, ) from dagster._core.definitions.partitions.definition import StaticPartitionsDefinition @asset def asset_a(): return [1, 2, 3] @asset def asset_b()...
227
5,247
dagster
python_modules/dagster-test/dagster_test/toys/run_status_sensors.py
.py
from time import time from dagster import ( DagsterRunStatus, JobSelector, RepositorySelector, RunRequest, SkipReason, job, op, run_failure_sensor, run_status_sensor, ) from dagster._core.definitions.run_request import DagsterRunReaction @op def succeeds(): return 1 @op def ...
237
6,217
dagster
python_modules/dagster-test/dagster_test/toys/external_assets.py
.py
from dagster import AssetMaterialization, AssetSpec, Definitions, OpExecutionContext, job, op asset_one = AssetSpec("asset_one") asset_two = AssetSpec("asset_two", deps=[asset_one]) @op def insert_materializations(context: OpExecutionContext) -> None: context.log_event( AssetMaterialization(asset_one.ke...
24
680
dagster
python_modules/dagster-test/dagster_test/toys/many_events.py
.py
from dagster import ( AssetMaterialization, ExpectationResult, In, MetadataValue, Nothing, Out, Output, file_relative_path, graph, op, ) MARKDOWN_EXAMPLE = "markdown_example.md" raw_files = [ "raw_file_users", "raw_file_groups", "raw_file_events", "raw_file_frie...
196
5,406
dagster
python_modules/dagster-test/dagster_test/toys/schedules.py
.py
import datetime from dagster import ( build_schedule_from_partitioned_job, daily_partitioned_config, hourly_partitioned_config, monthly_partitioned_config, schedule, weekly_partitioned_config, ) from dagster._core.definitions.run_request import RunRequest from dagster._core.definitions.schedule...
132
4,392
dagster
python_modules/dagster-test/dagster_test/toys/resources.py
.py
from dagster import Definitions, Field, Int, asset, graph, op, resource def define_resource(num): @resource(config_schema=Field(Int, is_required=False)) def a_resource(context): return num if context.resource_config is None else context.resource_config return a_resource lots_of_resources = {"R"...
60
1,183
dagster
python_modules/dagster-test/dagster_test/toys/branches.py
.py
from time import sleep from dagster import Field, Int, Out, Output, graph, op @op( config_schema={"sleep_secs": Field([int], is_required=False, default_value=[0, 0])}, out={"out_1": Out(Int), "out_2": Out(Int)}, ) def root(context): sleep_secs = context.op_config["sleep_secs"] yield Output(sleep_secs...
53
1,176
dagster
python_modules/dagster-test/dagster_test/toys/auto_materializing/lazy_repo_1.py
.py
from dagster import AutoMaterializePolicy, asset, repository from dagster._core.definitions.partitions.definition import DailyPartitionsDefinition daily_partitions_def = DailyPartitionsDefinition(start_date="2023-02-01") @asset(auto_materialize_policy=AutoMaterializePolicy.lazy()) def lazy_upstream(): return 1 ...
35
991
dagster
python_modules/dagster-test/dagster_test/toys/auto_materializing/large_graph.py
.py
import itertools from collections.abc import Sequence from typing import NamedTuple from dagster import ( AssetCheckResult, AssetCheckSpec, AssetKey, AssetsDefinition, AutoMaterializePolicy, AutomationCondition, MaterializeResult, PartitionsDefinition, asset, repository, ) from ...
122
4,524
dagster
python_modules/dagster-test/dagster_test/toys/auto_materializing/lazy_repo_2.py
.py
from dagster import AssetKey, AutoMaterializePolicy, SourceAsset, asset, repository from dagster._core.definitions.freshness_policy import LegacyFreshnessPolicy from dagster._core.definitions.partitions.definition import DailyPartitionsDefinition ### Non partitioned ### lazy_downstream_1_source = SourceAsset(AssetKey...
67
2,200
dagster
python_modules/dagster-test/dagster_test/toys/auto_materializing/repo_1.py
.py
from dagster import AutoMaterializePolicy, asset, repository from dagster._core.definitions.partitions.definition import ( DailyPartitionsDefinition, DynamicPartitionsDefinition, MultiPartitionsDefinition, ) ### Non partitioned ## @asset(auto_materialize_policy=AutoMaterializePolicy.eager()) def eager_up...
66
1,910
dagster
python_modules/dagster-test/dagster_test/toys/auto_materializing/repo_2.py
.py
from dagster import AssetKey, AutoMaterializePolicy, SourceAsset, asset, repository from dagster._core.definitions.partitions.definition import DailyPartitionsDefinition eager_downstream_1_source = SourceAsset(AssetKey(["eager_downstream_1"])) ### Non partitioned ### @asset(auto_materialize_policy=AutoMaterializePo...
60
2,028
dagster
python_modules/dagster-test/dagster_test/toys/pyspark_assets/pyspark_assets_job.py
.py
import importlib.util import os from dagster import Field, In, String, graph, op, resource _has_pyspark = importlib.util.find_spec("pyspark") is not None if not _has_pyspark: raise Exception("This example requires the pyspark package") from pyspark.sql import SparkSession, Window from pyspark.sql.functions impor...
168
5,067
dagster
python_modules/dagster-test/dagster_test/toys/partitioned_assets/different_static_partitions.py
.py
from dagster import AssetIn, asset from dagster._core.definitions.partitions.definition import StaticPartitionsDefinition from dagster._core.definitions.partitions.mapping import StaticPartitionMapping @asset(partitions_def=StaticPartitionsDefinition(["a", "b", "c"])) def static_partitioned_asset1(context): asser...
21
673
dagster
python_modules/dagster-test/dagster_test/toys/partitioned_assets/hourly_and_daily_and_unpartitioned.py
.py
from datetime import datetime from dagster import MetadataValue, asset from dagster._core.definitions.partitions.definition import ( DailyPartitionsDefinition, HourlyPartitionsDefinition, ) daily_partitions_def = DailyPartitionsDefinition(start_date="2020-01-01") @asset( metadata={"owner": "alice@exampl...
48
1,197
dagster
python_modules/dagster-test/dagster_test/toys/partitioned_assets/hourly_partitions_to_daily.py
.py
from dagster import asset from dagster._core.definitions.partitions.definition import ( DailyPartitionsDefinition, HourlyPartitionsDefinition, ) hourly_partitions_def = HourlyPartitionsDefinition(start_date="2023-02-01-00:00") daily_partitions_def = DailyPartitionsDefinition(start_date="2023-02-01") @asset(p...
21
584
dagster
python_modules/dagster-test/dagster_test/toys/partitioned_assets/with_backfill_policies.py
.py
from dagster import BackfillPolicy, MaterializeResult, asset from dagster._core.definitions.partitions.definition import DailyPartitionsDefinition @asset( partitions_def=DailyPartitionsDefinition(start_date="2023-01-01"), backfill_policy=BackfillPolicy.single_run(), group_name="with_backfill_policy", ) de...
21
677
dagster
python_modules/dagster-test/dagster_test/toys/partitioned_assets/partitioned_run_request_sensors.py
.py
import random from dagster import AssetSelection, RunRequest, SensorResult, define_asset_job, sensor from dagster_test.toys.partitioned_assets.dynamic_asset_partitions import ( ints_dynamic_asset, ints_dynamic_partitions_def, ) from dagster_test.toys.partitioned_assets.hourly_and_daily_and_unpartitioned impor...
57
2,227
dagster
python_modules/dagster-test/dagster_test/toys/partitioned_assets/single_partitions_to_multi.py
.py
from dagster import asset from dagster._core.definitions.partitions.definition import ( DynamicPartitionsDefinition, MultiPartitionsDefinition, StaticPartitionsDefinition, ) abc_def = StaticPartitionsDefinition(["a", "b", "c"]) composite = MultiPartitionsDefinition( { "abc": abc_def, "...
39
787
dagster
python_modules/dagster-test/dagster_test/toys/partitioned_assets/dynamic_asset_partitions.py
.py
import click from dagster import AssetSelection, DagsterInstance, asset, define_asset_job from dagster._core.definitions.partitions.definition import ( DailyPartitionsDefinition, DynamicPartitionsDefinition, MultiPartitionsDefinition, ) customers_partitions_def = DynamicPartitionsDefinition(name="customers...
60
1,834
dagster
python_modules/dagster-test/dagster_test/toys/partitioned_assets/failing_partitions.py
.py
from random import random from dagster import asset from dagster._core.definitions.partitions.definition import ( DailyPartitionsDefinition, MultiPartitionsDefinition, StaticPartitionsDefinition, ) from dagster_test.toys.partitioned_assets.dynamic_asset_partitions import ( multipartition_w_dynamic_par...
90
2,430
dagster
python_modules/dagster-test/dagster_test/toys/user_computed_data_versions/__init__.py
.py
"""Models a case where Dagster is used purely for orchestration and not data transformation. In this scenario, both the structure of the asset graph and the compute logic for assets are defined externally to Dagster. The asset graph is specified in a schema, and an external system knows how to compute each asset liste...
174
6,326
dagster
python_modules/dagster-test/dagster_test/toys/user_computed_data_versions/external_system.py
.py
import json import os from collections.abc import Mapping from dataclasses import asdict, dataclass from hashlib import sha256 from time import sleep from typing import AbstractSet, Any # noqa: UP035 from typing_extensions import TypedDict # For source assets _DUMMY_VALUE = 100 # ExternalSystem simulates source ass...
164
5,660
dagster
python_modules/dagster-test/dagster_test/toys/external_execution/__init__.py
.py
import os import sys from dagster import AssetExecutionContext, Config, Definitions, asset from dagster._core.pipes.subprocess import PipesSubprocessClient from pydantic import Field # Add package container to path sys.path.append(os.path.dirname(os.path.abspath(__file__))) def get_common_extras(context: AssetExecu...
85
2,291
dagster
python_modules/dagster-test/dagster_test/toys/external_execution/error_example/sleep_and_fail.py
.py
import time from dagster_pipes import open_dagster_pipes with open_dagster_pipes() as context: n = context.get_extra("sleep_seconds") context.log.info(f"sleeping for {n} seconds") time.sleep(n) raise Exception("oops all errors")
10
247
dagster
python_modules/dagster-test/dagster_test/toys/external_execution/numbers_example/number_x.py
.py
from dagster_pipes import open_dagster_pipes from dagster_test.toys.external_execution.numbers_example.util import ( compute_data_version, store_asset_value, ) with open_dagster_pipes() as context: storage_root = context.get_extra("storage_root") multiplier = context.get_extra("multiplier") value...
19
591
dagster
python_modules/dagster-test/dagster_test/toys/external_execution/numbers_example/number_y.py
.py
import os from dagster_pipes import open_dagster_pipes from dagster_test.toys.external_execution.numbers_example.util import ( compute_data_version, store_asset_value, ) with open_dagster_pipes() as context: storage_root = context.get_extra("storage_root") value = int(os.environ["NUMBER_Y"]) sto...
21
609
dagster
python_modules/dagster-test/dagster_test/toys/external_execution/numbers_example/util.py
.py
import hashlib import json import os def load_asset_value(asset_key: str, storage_path: str): with open(os.path.join(storage_path, asset_key), encoding="utf-8") as f: content = f.read() return json.loads(content) def store_asset_value(asset_key: str, storage_path: str, value: int): with open...
19
537
dagster
python_modules/dagster-test/dagster_test/toys/external_execution/numbers_example/number_sum.py
.py
from dagster_pipes import open_dagster_pipes from dagster_test.toys.external_execution.numbers_example.util import ( compute_data_version, load_asset_value, store_asset_value, ) with open_dagster_pipes() as context: storage_root = context.get_extra("storage_root") number_y = load_asset_value("numb...
18
652
dagster
python_modules/dagster-test/dagster_test/toys/asset_reconciliation/eager_reconciliation.py
.py
from dagster import AutoMaterializePolicy, Definitions, asset, load_assets_from_current_module @asset def root1(): ... @asset def root2(): ... @asset def diamond_left(root1): ... @asset def diamond_right(root1): ... @asset def diamond_sink(diamond_left, diamond_right): ... @asset def after_both_roots(root1,...
35
557
dagster
python_modules/dagster-test/dagster_test/toys/column_schema/column_schema_assets.py
.py
import datetime import random from dagster import MaterializeResult, TableColumn, TableSchema, asset @asset( owners=["claire@dagsterlabs.com"], tags={"tag_key": "value", "foo": "bar"}, compute_kind="dbt", description="asset_one_description", group_name="group1", metadata={ "dagster/co...
83
2,393
dagster
python_modules/dagster-test/dagster_test/benchmarks/partition_stale_status.py
.py
# ruff: noqa: T201 import argparse from collections.abc import Sequence from random import randint from dagster import asset from dagster._core.asset_graph_view.asset_graph_view import AssetGraphView, TemporalContext from dagster._core.definitions.assets.definition.assets_definition import AssetsDefinition from dagste...
208
8,659
dagster
python_modules/dagster-test/dagster_test/utils/benchmark.py
.py
import sys import time from collections.abc import Iterator, Mapping from contextlib import contextmanager from dataclasses import dataclass from typing import Any, TextIO from rich.console import Console from rich.table import Table from typing_extensions import Self @dataclass class ProfilingEntry: name: str ...
103
3,284
dagster
python_modules/dagster-test/dagster_test/utils/data_factory.py
.py
from collections.abc import ( Callable, Mapping, Sequence, Set as AbstractSet, ) from datetime import datetime from uuid import uuid4 from dagster import ( AssetCheckKey, AssetKey, DagsterEvent, DagsterEventType, DagsterRun, DagsterRunStatus, EventLogEntry, ) from dagster._c...
151
5,107
dagster
python_modules/dagster-test/dagster_test/utils/definitions_execute_in_process.py
.py
from collections.abc import Mapping from typing import TYPE_CHECKING, Any, Optional import dagster._check as check from dagster._core.definitions.job_definition import JobDefinition from dagster._core.definitions.run_config import RunConfig, convert_config_input from dagster._core.definitions.schedule_definition impor...
97
3,792
dagster
python_modules/dagster-test/dagster_test/fixtures/utils.py
.py
import os import signal import pytest import requests import requests.adapters from urllib3.util.retry import Retry BUILDKITE = os.environ.get("BUILDKITE") is not None @pytest.fixture(scope="session", autouse=True) def sigterm_handler(): # pytest finalizers don't run on SIGTERM; only SIGINT. # When Buildkit...
43
1,003
dagster
python_modules/dagster-test/dagster_test/fixtures/__init__.py
.py
from dagster_test.fixtures.docker_compose import ( default_docker_compose_yml as default_docker_compose_yml, docker_compose as docker_compose, docker_compose_cm as docker_compose_cm, docker_compose_cm_fixture as docker_compose_cm_fixture, dump_docker_compose_logs as dump_docker_compose_logs, net...
14
517
dagster
python_modules/dagster-test/dagster_test/fixtures/docker_compose.py
.py
import json import logging import os import subprocess import time from collections.abc import Mapping, Sequence from contextlib import contextmanager import pytest from dagster_shared.yaml_utils import safe_load_yaml from dagster_test.fixtures.utils import BUILDKITE # Hard upper bound on `docker compose up`. Set ge...
479
16,811
dagster
python_modules/dagster-test/dagster_test/components/all_metadata_empty_asset.py
.py
from dagster import Component, ComponentLoadContext from dagster._core.definitions.decorators.asset_decorator import asset from dagster._core.definitions.definitions_class import Definitions from dagster._core.execution.context.asset_execution_context import AssetExecutionContext class AllMetadataEmptyComponent(Compo...
16
570
dagster
python_modules/dagster-test/dagster_test/components/__init__.py
.py
from dagster_test.components.all_metadata_empty_asset import ( AllMetadataEmptyComponent as AllMetadataEmptyComponent, ) from dagster_test.components.complex_schema_asset import ( ComplexAssetComponent as ComplexAssetComponent, ) from dagster_test.components.simple_asset import SimpleAssetComponent as SimpleAss...
11
460
dagster
python_modules/dagster-test/dagster_test/components/complex_schema_asset.py
.py
from dataclasses import dataclass from dagster import Component, ComponentLoadContext, Resolvable from dagster._core.definitions.decorators.asset_decorator import asset from dagster._core.definitions.definitions_class import Definitions from dagster._core.execution.context.asset_execution_context import AssetExecution...
31
1,118
dagster
python_modules/dagster-test/dagster_test/components/simple_pipes_script_asset.py
.py
import shutil from pathlib import Path from dagster import Component, ComponentLoadContext, Model from dagster._core.definitions.asset_key import AssetKey from dagster._core.definitions.decorators.asset_decorator import asset from dagster._core.definitions.definitions_class import Definitions from dagster._core.execut...
73
2,660
dagster
python_modules/dagster-test/dagster_test/components/simple_asset.py
.py
from dagster import Component, ComponentLoadContext, ComponentTypeSpec, Model, Resolvable from dagster._core.definitions.decorators.asset_decorator import asset from dagster._core.definitions.definitions_class import Definitions from dagster._core.execution.context.asset_execution_context import AssetExecutionContext f...
32
1,163
dagster
python_modules/dagster-test/dagster_test/components/test_utils/test_cases.py
.py
from collections.abc import Callable from dataclasses import dataclass from pathlib import Path @dataclass class ComponentValidationTestCase: """A test case for validating a component, used to test raw YAML error messages as well as the check CLI. """ component_path: str component_type_filepath: ...
212
7,235
dagster
python_modules/dagster-test/dagster_test/components/test_utils/basic_components.py
.py
"""Sample local components for testing validation. Paired with test cases in integration_tests/integration_test_defs/validation. """ from collections.abc import Mapping from dataclasses import dataclass from typing import Annotated, Any from dagster._core.definitions.definitions_class import Definitions from dagster....
67
1,629
dagster
python_modules/dagster-test/dagster_test_tests/test_test_project.py
.py
from dagster._core.test_utils import instance_for_test from dagster_test.test_project import ( ReOriginatedExternalJobForTest, get_test_project_workspace_and_remote_job, ) def test_reoriginated_remote_job(): with instance_for_test() as instance: with get_test_project_workspace_and_remote_job(insta...
18
628
dagster
python_modules/dagster-test/dagster_test_tests/test_package_registry.py
.py
"""Test to ensure all Python packages in the repository are documented in python_packages.md.""" import re from pathlib import Path import pytest def get_repo_root() -> Path: """Get the repository root directory.""" current_dir = Path(__file__).resolve() # Navigate up from dagster-test/dagster_test_test...
188
6,630
dagster
python_modules/dagster-test/dagster_test_tests/test_toys.py
.py
from unittest import mock import pytest from dagster import ( DagsterEvent, DagsterInstance, DagsterResourceFunctionError, DagsterRun, DagsterTypeCheckDidNotPass, RunStatusSensorDefinition, build_run_status_sensor_context, build_sensor_context, multiprocess_executor, ) from dagster....
333
10,966
dagster
python_modules/dagster-test/dagster_test_tests/conftest.py
.py
import re import subprocess import warnings import pytest @pytest.fixture(scope="session", autouse=True) def kernel(): installed_kernels = [ x.split(" ")[0] for x in [ re.sub(" +", " ", x.strip(" ")) for x in filter( lambda x: x.startswith(" "), ...
28
837
dagster
python_modules/dagster-test/dagster_test_tests/fixtures_tests/test_docker_compose.py
.py
import os import subprocess import pytest import yaml from dagster_shared.yaml_utils import safe_load_yaml from dagster_test.fixtures.docker_compose import ( connect_container_to_network, disconnect_container_from_network, network_name_from_yml, ) pytest_plugins = ["dagster_test.fixtures"] @pytest.fixtu...
112
4,624
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/test_basic_assets.py
.py
from dagster import Definitions, load_assets_from_modules, mem_io_manager from dagster_test.toys import basic_assets def test_basic_assets_job(): Definitions( jobs=[basic_assets.basic_assets_job], assets=load_assets_from_modules([basic_assets]) ).resolve_job_def("basic_assets_job").execute_in_process(...
11
376
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/test_asset_sensors.py
.py
from dagster import build_multi_asset_sensor_context, instance_for_test, materialize from dagster_test.toys.asset_sensors import partitioned_assets, partitioned_multi_asset_sensor from dagster_test.toys.repo import assets_with_sensors_repository partitioned_asset = partitioned_assets[0] def test_partitioned_multi_as...
19
851
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/test_nothing_input.py
.py
from dagster_test.toys.nothing_input import nothing_job def test_nothing_input(): nothing_job.execute_in_process()
6
121
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/asset_reconciliation_tests/test_eager_reconciliation.py
.py
from dagster import mem_io_manager from dagster_test.toys.asset_reconciliation.eager_reconciliation import defs def test_assets(): defs.resolve_implicit_global_asset_job_def().execute_in_process( resources={"io_manager": mem_io_manager} )
9
257
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/partitioned_assets_tests/test_dynamic_asset_partitions.py
.py
from dagster import DagsterInstance, materialize_to_memory from dagster._core.definitions.partitions.utils import MultiPartitionKey from dagster_test.toys.partitioned_assets.dynamic_asset_partitions import ( customers_dynamic_partitions_asset1, customers_dynamic_partitions_asset2, customers_partitions_def, ...
36
1,488
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/partitioned_assets_tests/test_failing_partitions.py
.py
from dagster import Definitions, load_assets_from_modules from dagster_test.toys.partitioned_assets import failing_partitions def test_assets(): Definitions(assets=load_assets_from_modules([failing_partitions]))
7
218
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/partitioned_assets_tests/test_different_static_partitions.py
.py
import tempfile from dagster import DagsterInstance, materialize from dagster_test.toys.partitioned_assets.different_static_partitions import ( static_partitioned_asset1, static_partitioned_asset2, ) def test_assets(): with tempfile.TemporaryDirectory() as tmpdir_path: instance = DagsterInstance....
22
670
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/partitioned_assets_tests/test_sensors.py
.py
from dagster import build_sensor_context from dagster._core.test_utils import instance_for_test from dagster_test.toys.partitioned_assets.partitioned_run_request_sensors import ( ints_dynamic_partitions_asset_selection_sensor, ints_dynamic_partitions_job_sensor, upstream_daily_partitioned_asset_sensor, ) fr...
33
1,357
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/partitioned_assets_tests/test_single_partitions_to_multi.py
.py
import tempfile from dagster import DagsterInstance, materialize from dagster._core.definitions.partitions.utils import MultiPartitionKey from dagster_test.toys.partitioned_assets.single_partitions_to_multi import ( multi_partitions, single_partitions, ) def test_assets(): with tempfile.TemporaryDirector...
21
718
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/partitioned_assets_tests/test_hourly_and_daily_and_unpartitioned.py
.py
from dagster import Definitions, load_assets_from_modules from dagster._core.definitions.asset_key import AssetKey from dagster_test.toys.partitioned_assets import hourly_and_daily_and_unpartitioned def test_assets(): defs = Definitions(assets=load_assets_from_modules([hourly_and_daily_and_unpartitioned])) jo...
20
774
dagster
python_modules/dagster-test/dagster_test_tests/toys_tests/partitioned_assets_tests/test_hourly_partitions_to_daily.py
.py
import tempfile from dagster import DagsterInstance, materialize from dagster_test.toys.partitioned_assets.hourly_partitions_to_daily import ( daily_asset, hourly_asset1, hourly_asset2, ) def test_assets(): with tempfile.TemporaryDirectory() as tmpdir_path: instance = DagsterInstance.ephemera...
23
696
dagster
python_modules/dagster-graphql/dagster_graphql_tests/test_cli_repo.py
.py
from dagster import ScheduleDefinition, job, op, repository @op def add_one(num: int) -> int: return num + 1 @op def mult_two(num: int) -> int: return num * 2 @job def math(): mult_two(add_one()) @op(config_schema={"gimme": str}) def needs_config(context): return context.op_config["gimme"] @op...
49
791