PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
16.26k stars 1.58k forks source link

Make Prefect Cloud's user detail available via Prefect's Python Client #9722

Open PPPSDavid opened 1 year ago

PPPSDavid commented 1 year ago

First check

Prefect Version

2.x

Describe the current behavior

Currently, Prefect's API client returns a "CreatedBy" object for a flow run, which has an id, and a displayname. If this flow run is created by a user from the Prefect Cloud UI, the "displayname" of the CreatedBy object seems to be the sluggified version of the user's email account used during registration. (e.g. abc@qwe.com -> abcquecom).

We also noticed that in the Organization's User tab, each user also has a human-readable user name (in our case the user's name on file with our firm), but this does not seem to be accessible via the API.

Describe the proposed behavior

We can think of a couple of ways to close this gap:

  1. Add a function to the Prefect API that, given a user id, returns the full data model representing this user (account name, email, etc)
  2. Update the CreatedBy object to include the user's account name and email if possible. For flow runs from service account/Prefect schedule runs, these can just be None.

Example Use

Our team is using Prefect cloud with account access to orchestrate our flows, and we want to perform operations like the following systematically via the Prefect Python client:

Given a flow run, get me the account name & email of the person who kicked off it.

This is important because we want to have accountability as to who runs what, and also this will enable us to have custom notification rules that notify the flow creator if anything goes wrong.

Additional context

No response

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. To keep this issue open remove stale label or comment.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stale for 14 days with no activity. If this issue is important or you have more to add feel free to re-open it.

billpalombi commented 1 year ago

Sorry for allowing this to close. This is a great idea! Its not a high priority for us at the moment, but I've added it to our backlog.