diff --git a/examples/with_wandb/pyproject.toml b/examples/with_wandb/pyproject.toml index fed528d4a7a14..75d1baa65c0b3 100644 --- a/examples/with_wandb/pyproject.toml +++ b/examples/with_wandb/pyproject.toml @@ -1,3 +1,6 @@ [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" + +[tool.dagster] +module_name = "with_wandb" \ No newline at end of file diff --git a/examples/with_wandb/with_wandb/__init__.py b/examples/with_wandb/with_wandb/__init__.py index e69de29bb2d1d..ba95d6b0d5198 100644 --- a/examples/with_wandb/with_wandb/__init__.py +++ b/examples/with_wandb/with_wandb/__init__.py @@ -0,0 +1,38 @@ +from dagster import ( + Definitions, + StringSource, + load_assets_from_package_module, + make_values_resource, +) +from dagster_wandb import wandb_artifacts_io_manager, wandb_resource + +from . import assets +from .ops.launch.run_launch_agent import run_launch_agent_example +from .ops.launch.run_launch_job import run_launch_job_example +from .ops.partitioned_job import partitioned_job_example +from .ops.simple_job import simple_job_example + +wandb_config = make_values_resource( + entity=StringSource, + project=StringSource, +) + +defs = Definitions( + assets=load_assets_from_package_module(assets), + jobs=[ + simple_job_example, + partitioned_job_example, + run_launch_agent_example, + run_launch_job_example, + ], + resources={ + "wandb_config": wandb_config.configured( + { + "entity": {"env": "WANDB_ENTITY"}, + "project": {"env": "WANDB_PROJECT"}, + } + ), + "wandb_resource": wandb_resource.configured({"api_key": {"env": "WANDB_API_KEY"}}), + "io_manager": wandb_artifacts_io_manager.configured({"cache_duration_in_minutes": 60}), + }, +) diff --git a/examples/with_wandb/with_wandb/ops/__init__.py b/examples/with_wandb/with_wandb/ops/__init__.py deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/examples/with_wandb/with_wandb/repository.py b/examples/with_wandb/with_wandb/repository.py deleted file mode 100644 index 6b69bec996784..0000000000000 --- a/examples/with_wandb/with_wandb/repository.py +++ /dev/null @@ -1,45 +0,0 @@ -from dagster import ( - StringSource, - load_assets_from_package_module, - make_values_resource, - repository, - with_resources, -) -from dagster_wandb import wandb_artifacts_io_manager, wandb_resource - -from . import assets -from .ops.launch.run_launch_agent import run_launch_agent_example -from .ops.launch.run_launch_job import run_launch_job_example -from .ops.partitioned_job import partitioned_job_example -from .ops.simple_job import simple_job_example - - -@repository -def dagster_with_wandb(): - return [ - simple_job_example, - partitioned_job_example, - run_launch_agent_example, - run_launch_job_example, - *with_resources( - load_assets_from_package_module(assets), - resource_defs={ - "wandb_config": make_values_resource( - entity=StringSource, - project=StringSource, - ), - "wandb_resource": wandb_resource.configured({"api_key": {"env": "WANDB_API_KEY"}}), - "io_manager": wandb_artifacts_io_manager.configured( - {"cache_duration_in_minutes": 60} - ), - }, - resource_config_by_key={ - "wandb_config": { - "config": { - "entity": {"env": "WANDB_ENTITY"}, - "project": {"env": "WANDB_PROJECT"}, - } - } - }, - ), - ] diff --git a/examples/with_wandb/with_wandb_tests/test_basic_wanb_example.py b/examples/with_wandb/with_wandb_tests/test_basic_wanb_example.py index 9847d2a5f9ade..f40855782df94 100644 --- a/examples/with_wandb/with_wandb_tests/test_basic_wanb_example.py +++ b/examples/with_wandb/with_wandb_tests/test_basic_wanb_example.py @@ -1,5 +1,8 @@ -from with_wandb.repository import dagster_with_wandb +from with_wandb import defs -def test_can_load(): - assert dagster_with_wandb.get_job("simple_job_example") +def test_defs_can_load(): + assert defs.get_job_def("simple_job_example") + assert defs.get_job_def("partitioned_job_example") + assert defs.get_job_def("run_launch_agent_example") + assert defs.get_job_def("run_launch_job_example") diff --git a/examples/with_wandb/workspace.yaml b/examples/with_wandb/workspace.yaml deleted file mode 100644 index 7f34e9a542e50..0000000000000 --- a/examples/with_wandb/workspace.yaml +++ /dev/null @@ -1,2 +0,0 @@ -load_from: - - python_package: with_wandb