Skip to content

Commit

Permalink
Make load_definitions_from_module public (#26949)
Browse files Browse the repository at this point in the history
## Summary & Motivation
Exposes load_definitions_from_module as a public API, and mark it as experimental for now

## How I Tested These Changes

Existing tests
## Changelog
- A new function `load_definitions_from_module`, which can load all the assets, checks, schedules, sensors, and job objects within a module scope into a single Definitions object. Check out the documentation to learn more: https://docs.dagster.io/_apidocs/definitions#dagster.load_definitions_from_module
  • Loading branch information
dpeng817 authored Jan 8, 2025
1 parent 3840a94 commit b6be0b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/sphinx/sections/api/apidocs/definitions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ Definitions
.. autoclass:: Definitions
:members: get_job_def, get_sensor_def, get_schedule_def, load_asset_value, get_asset_value_loader

.. autofunction:: create_repository_using_definitions_args
.. autofunction:: create_repository_using_definitions_args

.. autofunction:: load_definitions_from_module
3 changes: 3 additions & 0 deletions python_modules/dagster/dagster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@
load_assets_from_package_module as load_assets_from_package_module,
load_assets_from_package_name as load_assets_from_package_name,
)
from dagster._core.definitions.module_loaders.load_defs_from_module import (
load_definitions_from_module as load_definitions_from_module,
)
from dagster._core.definitions.multi_asset_sensor_definition import (
MultiAssetSensorDefinition as MultiAssetSensorDefinition,
MultiAssetSensorEvaluationContext as MultiAssetSensorEvaluationContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from types import ModuleType
from typing import Any, Mapping, Optional, Union

from dagster._annotations import experimental
from dagster._core.definitions.definitions_class import Definitions
from dagster._core.definitions.executor_definition import ExecutorDefinition
from dagster._core.definitions.logger_definition import LoggerDefinition
from dagster._core.definitions.module_loaders.object_list import ModuleScopedDagsterDefs
from dagster._core.executor.base import Executor


@experimental
def load_definitions_from_module(
module: ModuleType,
resources: Optional[Mapping[str, Any]] = None,
Expand Down

2 comments on commit b6be0b5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagster-docs ready!

✅ Preview
https://dagster-docs-5nmeqahci-elementl.vercel.app
https://master.dagster.dagster-docs.io

Built with commit b6be0b5.
This pull request is being automatically deployed with vercel-action

@github-actions
Copy link

@github-actions github-actions bot commented on b6be0b5 Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagster-docs-beta ready!

✅ Preview
https://dagster-docs-beta-bih4s7qrs-elementl.vercel.app

Built with commit b6be0b5.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.