CachedMeta
CachedMeta Examples
Examples of using the CachedMeta class are listed at the bottom of this page Examples.
CachedMeta: A class that provides caching for the Meta() class
CachedMeta
Bases: CloudMeta
CachedMeta: Singleton class for caching metadata functionality.
Common Usage
from workbench.cached.cached_meta import CachedMeta
meta = CachedMeta()
# Get the AWS Account Info
meta.account()
meta.config()
# These are 'list' methods
meta.etl_jobs()
meta.data_sources()
meta.feature_sets(details=True/False)
meta.models(details=True/False)
meta.endpoints()
meta.views()
# These are 'describe' methods
meta.data_source("abalone_data")
meta.feature_set("abalone_features")
meta.model("abalone-regression")
meta.endpoint("abalone-endpoint")
Source code in src/workbench/cached/cached_meta.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
__del__()
__init__()
CachedMeta Initialization
Source code in src/workbench/cached/cached_meta.py
account()
Cloud Platform Account Info
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Cloud Platform Account Info |
check()
clear_meta_cache()
close()
Explicitly close the thread pool, if needed.
Source code in src/workbench/cached/cached_meta.py
config()
Return the current Workbench Configuration
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The current Workbench Configuration |
data_source(data_source_name, database='workbench')
Get the details of a specific Data Source
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_source_name
|
str
|
The name of the Data Source |
required |
database
|
str
|
The Glue database. Defaults to 'workbench'. |
'workbench'
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Union[dict, None]
|
The details of the Data Source (None if not found) |
Source code in src/workbench/cached/cached_meta.py
data_sources()
Get a summary of the Data Sources deployed in the Cloud Platform
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A summary of the Data Sources deployed in the Cloud Platform |
Source code in src/workbench/cached/cached_meta.py
endpoint(endpoint_name)
Get the details of a specific Endpoint
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint_name
|
str
|
The name of the Endpoint |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Union[dict, None]
|
The details of the Endpoint (None if not found) |
Source code in src/workbench/cached/cached_meta.py
endpoints()
Get a summary of the Endpoints deployed in the Cloud Platform
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A summary of the Endpoints in the Cloud Platform |
Source code in src/workbench/cached/cached_meta.py
etl_jobs()
Get summary data about Extract, Transform, Load (ETL) Jobs
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A summary of the ETL Jobs deployed in the Cloud Platform |
Source code in src/workbench/cached/cached_meta.py
feature_set(feature_set_name)
Get the details of a specific Feature Set
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feature_set_name
|
str
|
The name of the Feature Set |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Union[dict, None]
|
The details of the Feature Set (None if not found) |
Source code in src/workbench/cached/cached_meta.py
feature_sets(details=False)
Get a summary of the Feature Sets deployed in the Cloud Platform
Parameters:
Name | Type | Description | Default |
---|---|---|---|
details
|
bool
|
Include detailed information. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A summary of the Feature Sets deployed in the Cloud Platform |
Source code in src/workbench/cached/cached_meta.py
glue_job(job_name)
Get the details of a specific Glue Job
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_name
|
str
|
The name of the Glue Job |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Union[dict, None]
|
The details of the Glue Job (None if not found) |
Source code in src/workbench/cached/cached_meta.py
incoming_data()
Get summary data about data in the incoming raw data
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A summary of the incoming raw data |
list_meta_cache()
model(model_name)
Get the details of a specific Model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
str
|
The name of the Model |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
Union[dict, None]
|
The details of the Model (None if not found) |
Source code in src/workbench/cached/cached_meta.py
models(details=False)
Get a summary of the Models deployed in the Cloud Platform
Parameters:
Name | Type | Description | Default |
---|---|---|---|
details
|
bool
|
Include detailed information. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A summary of the Models deployed in the Cloud Platform |
Source code in src/workbench/cached/cached_meta.py
views(database='workbench')
Get a summary of the all the Views, for the given database, in AWS
Parameters:
Name | Type | Description | Default |
---|---|---|---|
database
|
str
|
Glue database. Defaults to 'workbench'. |
'workbench'
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A summary of all the Views, for the given database, in AWS |
Source code in src/workbench/cached/cached_meta.py
cache_result(method)
Decorator to cache method results in meta_cache
Source code in src/workbench/cached/cached_meta.py
Examples
These example show how to use the CachedMeta()
class to pull lists of artifacts from AWS. DataSources, FeatureSets, Models, Endpoints and more. If you're building a web interface plugin, the CachedMeta class is a great place to start.
Workbench REPL
If you'd like to see exactly what data/details you get back from the CachedMeta()
class, you can spin up the Workbench REPL, use the class and test out all the methods. Try it out! Workbench REPL
CachedMeta = CachedMeta()
model_df = CachedMeta.models()
model_df
Model Group Health Owner ... Input Status Description
0 wine-classification healthy - ... wine_features Completed Wine Classification Model
1 abalone-regression-full healthy - ... abalone_features Completed Abalone Regression Model
2 abalone-regression healthy - ... abalone_features Completed Abalone Regression Model
[3 rows x 10 columns]
List the Models in AWS
from workbench.cached.cached_meta import CachedMeta
# Create our CachedMeta Class and get a list of our Models
CachedMeta = CachedMeta()
model_df = CachedMeta.models()
print(f"Number of Models: {len(model_df)}")
print(model_df)
# Get more details data on the Models
model_names = model_df["Model Group"].tolist()
for name in model_names:
pprint(CachedMeta.model(name))
Output
Number of Models: 3
Model Group Health Owner ... Input Status Description
0 wine-classification healthy - ... wine_features Completed Wine Classification Model
1 abalone-regression-full healthy - ... abalone_features Completed Abalone Regression Model
2 abalone-regression healthy - ... abalone_features Completed Abalone Regression Model
[3 rows x 10 columns]
wine-classification
abalone-regression-full
abalone-regression
Getting Model Performance Metrics
from workbench.cached.cached_meta import CachedMeta
# Create our CachedMeta Class and get a list of our Models
CachedMeta = CachedMeta()
model_df = CachedMeta.models()
print(f"Number of Models: {len(model_df)}")
print(model_df)
# Get more details data on the Models
model_names = model_df["Model Group"].tolist()
for name in model_names[:5]:
model_details = CachedMeta.model(name)
print(f"\n\nModel: {name}")
performance_metrics = model_details["workbench_CachedMeta"]["workbench_inference_metrics"]
print(f"\tPerformance Metrics: {performance_metrics}")
Output
wine-classification
ARN: arn:aws:sagemaker:us-west-2:507740646243:model-package-group/wine-classification
Description: Wine Classification Model
Tags: wine::classification
Performance Metrics:
[{'wine_class': 'TypeA', 'precision': 1.0, 'recall': 1.0, 'fscore': 1.0, 'roc_auc': 1.0, 'support': 12}, {'wine_class': 'TypeB', 'precision': 1.0, 'recall': 1.0, 'fscore': 1.0, 'roc_auc': 1.0, 'support': 14}, {'wine_class': 'TypeC', 'precision': 1.0, 'recall': 1.0, 'fscore': 1.0, 'roc_auc': 1.0, 'support': 9}]
abalone-regression
ARN: arn:aws:sagemaker:us-west-2:507740646243:model-package-group/abalone-regression
Description: Abalone Regression Model
Tags: abalone::regression
Performance Metrics:
[{'MAE': 1.64, 'RMSE': 2.246, 'R2': 0.502, 'MAPE': 16.393, 'MedAE': 1.209, 'NumRows': 834}]
List the Endpoints in AWS
from pprint import pprint
from workbench.cached.cached_meta import CachedMeta
# Create our CachedMeta Class and get a list of our Endpoints
CachedMeta = CachedMeta()
endpoint_df = CachedMeta.endpoints()
print(f"Number of Endpoints: {len(endpoint_df)}")
print(endpoint_df)
# Get more details data on the Endpoints
endpoint_names = endpoint_df["Name"].tolist()
for name in endpoint_names:
pprint(CachedMeta.endpoint(name))
Output
Number of Endpoints: 2
Name Health Instance Created ... Status Variant Capture Samp(%)
0 wine-classification-end healthy Serverless (2GB/5) 2024-03-23 23:09 ... InService AllTraffic False -
1 abalone-regression-end healthy Serverless (2GB/5) 2024-03-23 21:11 ... InService AllTraffic False -
[2 rows x 10 columns]
wine-classification-end
<lots of details about endpoints>
Not Finding some particular AWS Data?
The Workbench CachedMeta API Class also has (details=True)
arguments, so make sure to check those out.