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

Add new property for filtering service account events #2405

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions examples/quickstart/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@
" dataset_trn, dataset_tst = feature_engineering()\n",
" else:\n",
" # Load the datasets from an older pipeline\n",
" dataset_trn = client.get_artifact_version(id=train_dataset_id)\n",
" dataset_tst = client.get_artifact_version(id=test_dataset_id) \n",
" dataset_trn = client.get_artifact_version(name_id_or_prefix=train_dataset_id)\n",
" dataset_tst = client.get_artifact_version(name_id_or_prefix=test_dataset_id) \n",
"\n",
" trained_model = model_trainer(\n",
" dataset_trn=dataset_trn,\n",
Expand Down Expand Up @@ -970,8 +970,8 @@
"@pipeline\n",
"def inference(preprocess_pipeline_id: UUID):\n",
" \"\"\"Model batch inference pipeline\"\"\"\n",
" # random_state = client.get_artifact_version(id=preprocess_pipeline_id).metadata[\"random_state\"].value\n",
" # target = client.get_artifact_version(id=preprocess_pipeline_id).run_metadata['target'].value\n",
" # random_state = client.get_artifact_version(name_id_or_prefix=preprocess_pipeline_id).metadata[\"random_state\"].value\n",
" # target = client.get_artifact_version(name_id_or_prefix=preprocess_pipeline_id).run_metadata['target'].value\n",
" random_state = 42\n",
" target = \"target\"\n",
"\n",
Expand All @@ -981,7 +981,7 @@
" df_inference = inference_preprocessor(\n",
" dataset_inf=df_inference,\n",
" # We use the preprocess pipeline from the feature engineering pipeline\n",
" preprocess_pipeline=client.get_artifact_version(id=preprocess_pipeline_id),\n",
" preprocess_pipeline=client.get_artifact_version(name_id_or_prefix=preprocess_pipeline_id),\n",
" target=target,\n",
" )\n",
" inference_predict(\n",
Expand Down
8 changes: 8 additions & 0 deletions src/zenml/analytics/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self) -> None:

self.user_id: Optional[UUID] = None
self.external_user_id: Optional[UUID] = None
self.executed_by_service_account: Optional[bool] = None
self.client_id: Optional[UUID] = None
self.server_id: Optional[UUID] = None

Expand Down Expand Up @@ -82,11 +83,17 @@ def __enter__(self) -> "AnalyticsContext":
auth_context = get_auth_context()
if auth_context is not None:
self.user_id = auth_context.user.id
self.executed_by_service_account = (
auth_context.user.is_service_account
)
self.external_user_id = auth_context.user.external_user_id
else:
# If the code is running on the client, use the default user.
active_user = gc.zen_store.get_user()
self.user_id = active_user.id
self.executed_by_service_account = (
active_user.is_service_account
)
self.external_user_id = active_user.external_user_id

# Fetch the `client_id`
Expand Down Expand Up @@ -247,6 +254,7 @@ def track(
"server_id": str(self.server_id),
"deployment_type": str(self.deployment_type),
"database_type": str(self.database_type),
"executed_by_service_account": self.executed_by_service_account,
}
)

Expand Down