Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Update recommended structure to remove Dagster code from __init__.py #23316

Merged

Conversation

maximearmstrong
Copy link
Contributor

@maximearmstrong maximearmstrong commented Jul 29, 2024

Summary & Motivation

This PR updates the recommended folder structure to include the Definitions object in definitions.py instead of __init__.py. It also updates related guides and references.

Tutorials in the docs are not yet updated. Will open more PRs:

  • Update the project in examples/
  • Update the tutorials in examples/
  • Update tutorials in docs
  • Update Dag Uni content
  • Update Dag Uni starter projects once we have a PR for Dag Uni content

How I Tested These Changes

make mdx-full-format

Copy link
Contributor Author

maximearmstrong commented Jul 29, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @maximearmstrong and the rest of your teammates on Graphite Graphite

Copy link

github-actions bot commented Jul 29, 2024

Deploy preview for dagster-docs ready!

Preview available at https://dagster-docs-61lwfsk2o-elementl.vercel.app
https://maxime-ds-375-remove-dagster-code-from-init-py-in-docs.dagster.dagster-docs.io

Direct link to changed pages:

@maximearmstrong maximearmstrong marked this pull request as ready for review July 29, 2024 20:28
@maximearmstrong maximearmstrong self-assigned this Jul 29, 2024
@maximearmstrong maximearmstrong changed the title [docs] Update recommded structure to remove Dagster code from __init__.py [docs] Update recommended structure to remove Dagster code from __init__.py Jul 29, 2024
@graphite-app graphite-app bot added the area: docs Related to documentation in general label Jul 29, 2024
@maximearmstrong maximearmstrong force-pushed the maxime/ds-375/remove-dagster-code-from-init-py-in-docs branch from a6e9d94 to 44b1d45 Compare July 31, 2024 13:35
@maximearmstrong maximearmstrong force-pushed the maxime/ds-375/remove-dagster-code-from-init-py-in-docs branch from 44b1d45 to c9cd6e3 Compare July 31, 2024 15:14
@maximearmstrong maximearmstrong force-pushed the maxime/ds-375/remove-dagster-code-from-init-py-in-docs branch from 5485c9d to 009d0bb Compare July 31, 2024 15:27
@@ -131,7 +132,7 @@ In this example, we grouped resources (e.g., database connections, Spark session

In complex projects, we find it helpful to make resources reusable and configured with pre-defined values via <PyObject object="configured" />. This approach allows your teammates to use a pre-defined resource set or make changes to shared resources, thus enabling more efficient project development.

This pattern also helps you easily execute jobs in different environments without code changes. In this example, we dynamically defined a code location based on the deployment in [`__init__.py`](https://github.com/dagster-io/dagster/blob/master/examples/project_fully_featured/project_fully_featured/\__init\_\_.py) and can keep all code the same across testing, local development, staging, and production. Read more about our recommendations in the [Transitioning data pipelines from Development to Production](/guides/dagster/transitioning-data-pipelines-from-development-to-production) guide.
This pattern also helps you easily execute jobs in different environments without code changes. In this example, we dynamically defined a code location based on the deployment in [`definitions.py`](https://github.com/dagster-io/dagster/blob/master/examples/project_fully_featured/project_fully_featured/\__init\_\_.py) and can keep all code the same across testing, local development, staging, and production. Read more about our recommendations in the [Transitioning data pipelines from Development to Production](/guides/dagster/transitioning-data-pipelines-from-development-to-production) guide.
Copy link
Contributor Author

@maximearmstrong maximearmstrong Jul 31, 2024

Choose a reason for hiding this comment

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

URL to be updated here after changes to project-fully-featured are merged here.

Copy link
Contributor

Choose a reason for hiding this comment

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

@maximearmstrong linked PR has been approved if you want to merge / update URL.

@maximearmstrong maximearmstrong force-pushed the maxime/ds-375/remove-dagster-code-from-init-py-in-docs branch 2 times, most recently from fbf7d39 to df8e566 Compare August 1, 2024 13:38
Copy link
Contributor

@erinkcochran87 erinkcochran87 left a comment

Choose a reason for hiding this comment

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

Left two suggestions, but it's looking good!

docs/content/concepts/code-locations.mdx Outdated Show resolved Hide resolved
@@ -20,20 +20,20 @@ dagster dev -f my_file.py -f my_second_file.py
</TabItem>
<TabItem name="From a module">

Dagster can also load Python modules as [code locations](/concepts/code-locations). When this approach is used, Dagster loads the definitions defined at the top-level of the module, in a variable containing the <PyObject object="Definitions" /> object of its root `__init__.py` file. As this style of development eliminates an entire class of Python import errors, we strongly recommend it for Dagster projects deployed to production.
Dagster can also load Python modules as [code locations](/concepts/code-locations). When this approach is used, Dagster loads the definitions defined in the module passed to the command line. It is recommended to define a variable containing the <PyObject object="Definitions" /> object in a submodule named `definitions` inside the Python module. In practice, the submodule can be created by adding a file named `definitions.py` at the root level of the Python module. As this style of development eliminates an entire class of Python import errors, we strongly recommend it for Dagster projects deployed to production.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Dagster can also load Python modules as [code locations](/concepts/code-locations). When this approach is used, Dagster loads the definitions defined in the module passed to the command line. It is recommended to define a variable containing the <PyObject object="Definitions" /> object in a submodule named `definitions` inside the Python module. In practice, the submodule can be created by adding a file named `definitions.py` at the root level of the Python module. As this style of development eliminates an entire class of Python import errors, we strongly recommend it for Dagster projects deployed to production.
Dagster can also load Python modules as [code locations](/concepts/code-locations). When this approach is used, Dagster loads the definitions defined in the module passed to the command line.
We recommend defining a variable containing the <PyObject object="Definitions" /> object in a submodule named `definitions` inside the Python module. In practice, the submodule can be created by adding a file named `definitions.py` at the root level of the Python module.
As this style of development eliminates an entire class of Python import errors, we strongly recommend it for Dagster projects deployed to production.

Let's break this up a bit - the paragraph is pretty visually dense and there's a lot to take in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 32844cf

@maximearmstrong maximearmstrong force-pushed the maxime/ds-375/remove-dagster-code-from-init-py-in-docs branch from df8e566 to 32844cf Compare August 5, 2024 21:27
@maximearmstrong maximearmstrong merged commit 21af092 into master Aug 13, 2024
2 checks passed
@maximearmstrong maximearmstrong deleted the maxime/ds-375/remove-dagster-code-from-init-py-in-docs branch August 13, 2024 13:13
maximearmstrong added a commit that referenced this pull request Aug 13, 2024
## Summary & Motivation

This PR updates the URL to the file containing Definitions in
project-fully-featured. That was moved from #23316 to this PR to avoid
failure when running the doc tests - the file must exist before being
referenced, and it is updated in #23345.

## How I Tested These Changes

BK
PedramNavid pushed a commit that referenced this pull request Aug 14, 2024
…it__.py` (#23316)

## Summary & Motivation

This PR updates the recommended folder structure to include the
Definitions object in `definitions.py` instead of `__init__.py`. It also
updates related guides and references.

Tutorials in the docs are not yet updated. Will open more PRs:
- Update the project in examples/
- Update the tutorials in examples/
- Update tutorials in docs
- Update Dag Uni content
- Update Dag Uni starter projects once we have a PR for Dag Uni content

## How I Tested These Changes

make mdx-full-format
PedramNavid pushed a commit that referenced this pull request Aug 14, 2024
## Summary & Motivation

This PR updates the URL to the file containing Definitions in
project-fully-featured. That was moved from #23316 to this PR to avoid
failure when running the doc tests - the file must exist before being
referenced, and it is updated in #23345.

## How I Tested These Changes

BK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: docs Related to documentation in general
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants