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] display preview warning and decorator info #26819

Merged
merged 7 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/content/about/releases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ The "experimental" marker allows us to offer new APIs to users and rapidly itera

Experimental APIs may change or disappear within any release, but we try to avoid breaking them within minor releases if they have been around for a long time.

### Preview APIs

The "preview" marker allows us to offer APIs in early testing phase to users and rapidly iterate based on their feedback. Preview APIs are marked as such in the [API reference](/\_apidocs) and usually raise a <PyObject object="PreviewWarning" module="dagster._utils.warnings" /> when used.

Preview APIs may change or disappear within any release and are not considered ready for production use.

### Superseded APIs

The "superseded" marker indicates that we recommend avoiding an API, usually because there's a preferred option that should be used instead.
Expand Down
1 change: 1 addition & 0 deletions docs/markdoc-component-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ We've also got a bunch of badges that you can use to indicate the level of suppo
There are the available badges:

- `{% experimental /%}` {% experimental /%}
- `{% preview /%}` {% preview /%}
- `{% deprecated /%}` {% deprecated /%}
- `{% superseded /%}` {% superseded /%}
- `{% legacy /%}` {% legacy /%}
Expand Down
8 changes: 8 additions & 0 deletions docs/next/components/markdoc/Badges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ export const Experimental = () => {
);
};

export const Preview = () => {
return (
<div className="preview-tag">
<span className="hidden">(</span>Preview<span className="hidden">)</span>
</div>
);
};

export const Deprecated = () => {
return (
<div className="deprecated-tag">
Expand Down
13 changes: 13 additions & 0 deletions docs/next/components/mdx/MDXComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,18 @@ const Experimental = () => {
);
};

////////////////////////
// Preview BADGE //
////////////////////////

const Preview = () => {
return (
<div className="preview-tag">
<span className="hidden">(</span>Preview<span className="hidden">)</span>
</div>
);
};

////////////////////////
// DEPRECATED BADGE //
////////////////////////
Expand Down Expand Up @@ -866,6 +878,7 @@ export default {
Experimental,
Deprecated,
Superseded,
Preview,
Legacy,
Icons,
ReferenceTable,
Expand Down
7 changes: 6 additions & 1 deletion docs/next/markdoc/tags.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ArticleList, ArticleListItem} from '../components/markdoc/ArticleList';
import {Badge, Experimental, Deprecated, Superseded, Legacy} from '../components/markdoc/Badges';
import {Badge, Experimental, Preview, Deprecated, Superseded, Legacy} from '../components/markdoc/Badges';
import {Button, ButtonContainer} from '../components/markdoc/Button';
import {Note, Warning} from '../components/markdoc/Callouts';
import {Check, Cross} from '../components/markdoc/CheckCross';
Expand Down Expand Up @@ -80,6 +80,11 @@ export const experimental = {
selfClosing: true,
};

export const preview = {
render: Preview,
selfClosing: true,
};

export const deprecated = {
render: Deprecated,
selfClosing: true,
Expand Down
5 changes: 5 additions & 0 deletions docs/next/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ dt > a.reference.internal {
@apply inline-flex items-center px-3 py-0.5 rounded-full align-middle text-xs uppercase font-medium bg-sea-foam text-gable-green
}

.preview-tag,
.flag.preview{
Copy link
Member

Choose a reason for hiding this comment

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

Linter should probably catch this, but

Suggested change
.flag.preview{
.flag.preview {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks!

@apply inline-flex items-center px-3 py-0.5 rounded-full align-middle text-xs uppercase font-medium bg-sea-foam text-gable-green
}

.deprecated-tag {
@apply inline-flex items-center px-3 py-0.5 rounded-full align-middle text-xs uppercase font-medium bg-gray-300 text-gray-900
}
Expand Down
5 changes: 5 additions & 0 deletions docs/sphinx/_ext/dagster-sphinx/dagster_sphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
get_deprecated_params,
get_experimental_info,
get_experimental_params,
get_preview_info,
get_superseded_info,
has_deprecated_params,
has_experimental_params,
is_deprecated,
is_experimental,
is_preview,
is_public,
is_superseded,
)
Expand Down Expand Up @@ -126,6 +128,9 @@ def process_docstring(
if is_superseded(obj):
inject_object_flag(obj, get_superseded_info(obj), lines)

if is_preview(obj):
inject_object_flag(obj, get_preview_info(obj), lines)

if has_deprecated_params(obj):
params = get_deprecated_params(obj)
for param, info in params.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import dagster._check as check
import docutils.nodes as nodes
from dagster._annotations import DeprecatedInfo, ExperimentalInfo, SupersededInfo
from dagster._annotations import DeprecatedInfo, ExperimentalInfo, PreviewInfo, SupersededInfo

from sphinx.util.docutils import SphinxDirective

Expand All @@ -15,7 +15,9 @@


def inject_object_flag(
obj: object, info: Union[SupersededInfo, DeprecatedInfo, ExperimentalInfo], docstring: list[str]
obj: object,
info: Union[SupersededInfo, DeprecatedInfo, ExperimentalInfo, PreviewInfo],
docstring: list[str],
) -> None:
if isinstance(info, DeprecatedInfo):
additional_text = f" {info.additional_warn_text}." if info.additional_warn_text else ""
Expand All @@ -31,6 +33,13 @@ def inject_object_flag(
additional_text = f" {info.additional_warn_text}." if info.additional_warn_text else ""
flag_type = "superseded"
message = f"This API has been superseded and its usage is discouraged.\n{additional_text}"
elif isinstance(info, PreviewInfo):
additional_text = f" {info.additional_warn_text}." if info.additional_warn_text else ""
flag_type = "preview"
message = (
f"This API is currently in preview, and may have breaking changes in patch version releases. "
f"This API is not considered ready for production use.\n{additional_text}"
)
else:
check.failed(f"Unexpected info type {type(info)}")
for line in reversed([f".. flag:: {flag_type}", "", f" {message}", ""]):
Expand Down
2 changes: 2 additions & 0 deletions docs/sphinx/sections/api/apidocs/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Utilities

.. autoclass:: ExperimentalWarning

.. autoclass:: dagster._utils.warnings.PreviewWarning

.. autofunction:: make_email_on_run_failure_sensor

.. currentmodule:: dagster._utils.forked_pdb
Expand Down
Loading