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

Feature: JSON Artifacts #12295

Merged
merged 14 commits into from
Mar 28, 2024
Merged

Feature: JSON Artifacts #12295

merged 14 commits into from
Mar 28, 2024

Conversation

aaazzam
Copy link
Contributor

@aaazzam aaazzam commented Mar 13, 2024

Mostly a refactor of our public artifact methods.

The biggest change is a new public class-based interface to Artifacts, which:

  • defaults the artifact type to json.
  • enables a get by key, which was previously available only through the CLI.
  • enables a get_or_create by key, which does what you think it does.

I'm doing a draft PR

  • because there are no tests written,
  • to get feedback on the DevEx, and
  • there's some UI work to be done so that it doesn't just say "Unknown" everywhere.
Screenshot 2024-03-13 at 6 32 25 PM e738d07-beed-4be4-99cc-c78abb709ae6">

Copy link

netlify bot commented Mar 13, 2024

Deploy Preview for prefect-docs-preview ready!

Name Link
🔨 Latest commit 7d10672
🔍 Latest deploy log https://app.netlify.com/sites/prefect-docs-preview/deploys/6605a21864659f00086e8cfc
😎 Deploy Preview https://deploy-preview-12295--prefect-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@jakekaplan jakekaplan left a comment

Choose a reason for hiding this comment

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

Makes sense to me! I like using a class method for creation. It makes it feel more like it's making a thing

@aaazzam aaazzam marked this pull request as ready for review March 20, 2024 21:54
@aaazzam aaazzam requested a review from a team as a code owner March 20, 2024 21:54
@aaazzam
Copy link
Contributor Author

aaazzam commented Mar 20, 2024

@jakekaplan want to give it another once over?

@serinamarie serinamarie added the enhancement An improvement of an existing feature label Mar 21, 2024
Comment on lines +29 to +35
Arguments:
type: A string identifying the type of artifact.
key: A user-provided string identifier.
The key must only contain lowercase letters, numbers, and dashes.
description: A user-specified description of the artifact.
data: A JSON payload that allows for a result to be retrieved.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

should we note the optional args here?

data: Optional[Union[Dict[str, Any], Any]] = None,
client: Optional[PrefectClient] = None,
**kwargs: Any,
) -> Tuple[ArtifactResponse, bool]:
Copy link
Contributor

@jakekaplan jakekaplan Mar 21, 2024

Choose a reason for hiding this comment

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

What would you think about this just returning the artifact? It feels more unified with the other methods to keep the response shape/type the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am part of the anti-tuple response movement 🙃

Comment on lines +82 to +85
await client.read_artifacts(
limit=1,
sort=ArtifactSort.UPDATED_DESC,
artifact_filter=ArtifactFilter(key=ArtifactFilterKey(any_=[key])),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you'll need to add a client method for it but there is a more efficient lookup here:

https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/artifacts.py#L64-L80

Copy link
Contributor

@jakekaplan jakekaplan left a comment

Choose a reason for hiding this comment

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

Couple comments, otherwise LGTM

@aaazzam aaazzam merged commit 8577a34 into main Mar 28, 2024
48 checks passed
@aaazzam aaazzam deleted the json-artifact branch March 28, 2024 17:35
serinamarie pushed a commit that referenced this pull request Apr 5, 2024
Co-authored-by: Andrew Brookins <andrew.b@prefect.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants