Cards
Card
¶
Represents a card from a given registry that can be used in a card deck
Source code in python/opsml/card/_card.pyi
990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 |
|
__init__(alias, registry_type, space, name, version, uid, card)
¶
Initialize the card deck. Card accepts either a combination of space and name (with version as optional) or a uid. If only space and name are provided with no version, the latest version for a given space and name will be used (e.g. {space}/{name}/v). If a version is provided, it must follow semver rules that are compatible with opsml (e.g. v1., v1.2.3, v2.3.4-alpha, etc.). If both space/name and uid are provided, the uid will take precedence. If neither space/name nor uid are provided, an error will be raised.
Alias is used to identify the card in the card deck and is not necessarily the name of the card. It is recommended to use a short and descriptive alias that is easy to remember.
Example:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alias
|
str
|
The alias of the card |
required |
registry_type
|
RegistryType
|
The type of registry the card deck belongs to. This is required if no card is provided. |
required |
space
|
str
|
The space of the card deck |
required |
name
|
str
|
The name of the card deck |
required |
version
|
str
|
The version of the card deck |
required |
uid
|
str
|
The uid of the card deck |
required |
card
|
Union[DataCard, ModelCard, PromptCard, ExperimentCard]
|
Optional card to add to the deck. If provided, arguments will be extracted from the card. This card must be registered in a registry. |
required |
Example:
from opsml import Card, CardDeck, RegistryType
# With arguments
card = Card(
alias="my_alias",
registry_type=RegistryType.Model,
space="my_space",
name="my_name",
version="1.0.0",
)
# With card uid
card = Card(
alias="my_alias",
registry_type=RegistryType.Model,
uid="my_uid",
)
# With registered card
card = Card(
alias="my_alias",
card=model_card, # ModelCard object
)
Source code in python/opsml/card/_card.pyi
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 |
|
CardDeck
¶
Creates a CardDeck to hold a collection of cards.
Source code in python/opsml/card/_card.pyi
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 |
|
cards
property
¶
Return the cards in the card deck
created_at
property
¶
Return the created at timestamp
name
property
¶
Return the name of the card deck
opsml_version
property
¶
Return the opsml version
space
property
¶
Return the space of the card deck
uid
property
¶
Return the uid of the card deck
version
property
¶
Return the version of the card deck
__getitem__(alias)
¶
Get a card from the card deck by alias
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alias
|
str
|
The alias of the card to get |
required |
Returns:
Name | Type | Description |
---|---|---|
Card |
CardType
|
The card with the given alias |
__init__(space, name, cards, version)
¶
Initialize the card deck
Parameters:
Name | Type | Description | Default |
---|---|---|---|
space
|
str
|
The space of the card deck |
required |
name
|
str
|
The name of the card deck |
required |
cards
|
List[Card]
|
The cards in the card deck |
required |
version
|
str | None
|
The version of the card deck. If not provided, the latest version for a given space and name will be used (e.g. {space}/{name}/v*). |
required |
Source code in python/opsml/card/_card.pyi
download_artifacts(path=None)
¶
Download artifacts associated with each card in the card deck. This method will always overwrite existing artifacts.
If the path is not provided, the artifacts will be saved to a directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Top-level Path to download the artifacts to. If not provided, the artifacts will be saved to a directory using the CardDeck name. |
None
|
Source code in python/opsml/card/_card.pyi
from_path(path=None, load_kwargs=None)
staticmethod
¶
Loads a card deck and its associated cards from a filesystem path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to load the card deck from. Defaults to "card_deck". |
None
|
load_kwargs
|
Dict[str, Dict[str, Any]]
|
Optional kwargs for loading cards. Expected format: { "card_alias": { "interface": interface_object, "load_kwargs": DataLoadKwargs | ModelLoadKwargs } } |
None
|
Returns:
Name | Type | Description |
---|---|---|
CardDeck |
CardDeck
|
The loaded card deck with all cards instantiated. |
Raises:
Type | Description |
---|---|
PyError
|
If card deck JSON cannot be read |
PyError
|
If cards cannot be loaded |
PyError
|
If invalid kwargs are provided |
Example
Source code in python/opsml/card/_card.pyi
load(load_kwargs=None)
¶
Call the load method on each Card that requires additional loading. This applies to ModelCards and DataCards. PromptCards and ExperimentCards do not require additional loading and are loaded automatically when loading the CardDeck from the registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
load_kwargs
|
Dict[str, ModelLoadKwargs | DataLoadKwargs]
|
Optional kwargs for loading cards. Expected format: { "card_alias": DataLoadKwargs | ModelLoadKwargs } |
None
|
Source code in python/opsml/card/_card.pyi
model_validate_json(json_string)
¶
Load card deck from json string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string
|
str
|
The json string to validate |
required |
save(path)
¶
Save the card deck to a directory
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to save the card deck. |
required |
CardList
¶
Source code in python/opsml/card/_card.pyi
CardRecord
¶
Source code in python/opsml/card/_card.pyi
__str__()
¶
CardRegistry
¶
Bases: Generic[CardType]
Source code in python/opsml/card/_card.pyi
1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 |
|
mode
property
¶
Returns the mode of the registry
registry_type
property
¶
Returns the type of registry
table_name
property
¶
Returns the table name for the registry
__init__(registry_type)
¶
Interface for connecting to any of the Card registries
Parameters:
Name | Type | Description | Default |
---|---|---|---|
registry_type
|
RegistryType | str
|
The type of registry to connect to. Can be a |
required |
Returns:
Type | Description |
---|---|
None
|
Instantiated connection to specific Card registry |
Example:
data_registry = CardRegistry(RegistryType.Data)
data_registry.list_cards()
or
data_registry = CardRegistry("data")
data_registry.list_cards()
Source code in python/opsml/card/_card.pyi
delete_card(card)
¶
Delete a Card from the registry. This will also remove the underlying artifacts associated with the card.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
card
|
ArtifactCard
|
Card to delete. Can be a DataCard, ModelCard, experimentcard. |
required |
Source code in python/opsml/card/_card.pyi
list_cards(uid=None, space=None, name=None, version=None, max_date=None, tags=None, sort_by_timestamp=False, limit=25)
¶
Retrieves records from registry
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
Unique identifier for Card. If present, the uid takes precedence |
None
|
space
|
str
|
Optional space associated with card |
None
|
name
|
str
|
Optional name of card |
None
|
version
|
str
|
Optional version number of existing data. If not specified, the most recent version will be used |
None
|
tags
|
List[str]
|
Optional list of tags to search for |
None
|
max_date
|
str
|
Optional max date to search. (e.g. "2023-05-01" would search for cards up to and including "2023-05-01"). Must be in the format "YYYY-MM-DD" |
None
|
sort_by_timestamp
|
Optional[bool]
|
If True, sorts by timestamp descending |
False
|
limit
|
int
|
Places a limit on result list. Results are sorted by SemVer. Defaults to 25. |
25
|
Returns:
Type | Description |
---|---|
CardList
|
List of Cards |
Source code in python/opsml/card/_card.pyi
load_card(uid=None, space=None, name=None, version=None, interface=None)
¶
load_card(
uid: Optional[str] = None,
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
interface: Optional[DataInterface] = None,
) -> DataCard
load_card(
uid: Optional[str] = None,
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
interface=Optional[CardDeckInterfaceType],
) -> CardDeck
load_card(
uid: Optional[str] = None,
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
interface: Optional[ModelInterface] = None,
) -> ModelCard
Load a Card from the registry
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
Unique identifier for Card. If present, the uid takes precedence over space/name/version. |
None
|
space
|
str
|
Space associated with the card. |
None
|
name
|
str
|
Name of the card. |
None
|
version
|
str
|
Version number of existing card. If not specified, the most recent version will be used. |
None
|
interface
|
LoadInterfaceType
|
Interface to load the card with. Required for cards registered with custom interfaces. The expected interface type depends on the registry:
|
None
|
Returns:
Type | Description |
---|---|
Union[DataCard, ModelCard, PromptCard, ExperimentCard, CardDeck]
|
Union[DataCard, ModelCard, PromptCard, ExperimentCard, CardDeck]: The loaded card instance from the registry. |
Source code in python/opsml/card/_card.pyi
register_card(card, version_type=VersionType.Minor, pre_tag=None, build_tag=None, save_kwargs=Optional[ModelSaveKwargs | DataSaveKwargs])
¶
Register a Card
Parameters:
Name | Type | Description | Default |
---|---|---|---|
card
|
ArtifactCard
|
Card to register. Can be a DataCard, ModelCard, experimentcard. |
required |
version_type
|
VersionType
|
How to increment the version SemVer. |
Minor
|
pre_tag
|
str
|
Optional pre tag to associate with the version. |
None
|
build_tag
|
str
|
Optional build_tag to associate with the version. |
None
|
save_kwargs
|
SaveKwargs
|
Optional SaveKwargs to pass to the Card interface (If using DataCards and ModelCards). |
Optional[ModelSaveKwargs | DataSaveKwargs]
|
Source code in python/opsml/card/_card.pyi
update_card(card)
¶
Update a Card in the registry. Note: This will only update the registry record for a given card. It will not re-save/update the underlying artifacts (except for metadata).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
card
|
ArtifactCard
|
Card to update. Can be a DataCard, ModelCard, experimentcard. |
required |
Source code in python/opsml/card/_card.pyi
DataCard
¶
Source code in python/opsml/card/_card.pyi
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 295 296 297 298 299 300 301 302 |
|
app_env
property
¶
Returns the app env
created_at
property
¶
Returns the created at timestamp
data
property
¶
Return the data. This is a special property that is used to access the data from the interface. It is not settable. It will also raise an error if the interface is not set or if the data has not been loaded.
data_type
property
¶
Return the data type
experimentcard_uid
property
writable
¶
Return the experimentcard uid
interface
property
writable
¶
Return the data interface
metadata
property
¶
Return the metadata of the data card
name
property
writable
¶
Return the name of the data card
registry_type
property
¶
Return the card type of the data card
space
property
writable
¶
Return the space of the data card
tags
property
writable
¶
Return the tags of the data card
uid
property
¶
Return the uid of the data card
version
property
writable
¶
Return the version of the data card
__init__(interface=None, space=None, name=None, version=None, uid=None, tags=[])
¶
Define a data card
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interface
|
DataInterface | None
|
The data interface |
None
|
space
|
str | None
|
The space of the card |
None
|
name
|
str | None
|
The name of the card |
None
|
version
|
str | None
|
The version of the card |
None
|
uid
|
str | None
|
The uid of the card |
None
|
tags
|
List[str]
|
The tags of the card |
[]
|
Example:
from opsml import DataCard, CardRegistry, RegistryType, PandasData
# for testing purposes
from opsml.helpers.data import create_fake_data
# pandas data
X, _ = create_fake_data(n_samples=1200)
interface = PandasData(data=X)
datacard = DataCard(
interface=interface,
space="my-repo",
name="my-name",
tags=["foo:bar", "baz:qux"],
)
# register card
registry = CardRegistry(RegistryType.Data)
registry.register_card(datacard)
Source code in python/opsml/card/_card.pyi
download_artifacts(path=None)
¶
Download artifacts associated with the DataCard
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to save the artifacts. If not provided, the artifacts will be saved to a directory called "card_artifacts" |
None
|
Source code in python/opsml/card/_card.pyi
load(path=None, load_kwargs=None)
¶
Load the data card
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path | None
|
The path to load the data card from. If no path is provided, the data interface will be loaded from the server. |
None
|
load_kwargs
|
DataLoadKwargs | None
|
Optional load kwargs to that will be passed to the data interface load method |
None
|
Source code in python/opsml/card/_card.pyi
model_dump_json()
¶
model_validate_json(json_string, interface=None)
staticmethod
¶
Validate the model json string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string
|
str
|
The json string to validate |
required |
interface
|
DataInterface
|
By default, the interface will be inferred and instantiated from the interface metadata. If an interface is provided (as in the case of custom interfaces), it will be used. |
None
|
Source code in python/opsml/card/_card.pyi
save(path, save_kwargs=None)
¶
Save the data card
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
The path to save the data card to |
required |
save_kwargs
|
DataSaveKwargs | None
|
Optional save kwargs to that will be passed to the data interface save method |
None
|
Acceptable save kwargs
Kwargs are passed to the underlying data interface for saving. For a complete list of options see the save method of the data interface and their associated libraries.
Source code in python/opsml/card/_card.pyi
DataCardMetadata
¶
Source code in python/opsml/card/_card.pyi
ExperimentCard
¶
Source code in python/opsml/card/_card.pyi
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 |
|
app_env
property
¶
Returns the app env
artifacts
property
¶
Returns the artifact names
compute_environment
property
¶
Returns the compute env
created_at
property
¶
Returns the created at timestamp
name
property
writable
¶
Returns the name of the ModelCard
registry_type
property
¶
Returns the card type of the experimentcard
space
property
writable
¶
Returns the space of the experimentcard
tags
property
¶
Returns the tags of the ExperimentCard
uid
property
¶
Returns the uid of the experimentcard
uids
property
¶
Returns the uids of the experimentcard
version
property
writable
¶
Returns the version of the experimentcard
__init__(space=None, name=None, version=None, uid=None, tags=[])
¶
Instantiates a ExperimentCard.
Cards are stored in the ExperimentCard Registry and follow the naming convention of: {registry}/{space}/{name}/v{version}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
space
|
str | None
|
space to associate with |
None
|
name
|
str | None
|
Name to associate with |
None
|
version
|
str | None
|
Current version (assigned if card has been registered). Follows semantic versioning. |
None
|
uid
|
str | None
|
Unique id (assigned if card has been registered) |
None
|
tags
|
List[str]
|
Tags to associate with |
[]
|
Example:
from opsml import start_experiment
# start an experiment
with start_experiment(space="test", log_hardware=True) as exp:
exp.log_metric("accuracy", 0.95)
exp.log_parameter("epochs", 10)
Source code in python/opsml/card/_card.pyi
__str__()
¶
Return a string representation of the ExperimentCard
.
Returns:
Type | Description |
---|---|
str
|
String representation of the ModelCard. |
add_child_experiment(uid)
¶
Add a child experiment to the experiment card
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
The experiment card uid to add |
required |
download_artifacts(path=None, lpath=None)
¶
Download artifacts associated with the ExperimentCard
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path | None
|
Specific path you wish to download artifacts from. If not provided, all artifacts will be downloaded. |
None
|
lpath
|
Path | None
|
Local path to save the artifacts. If not provided, the artifacts will be saved to a directory called "artifacts" |
None
|
Source code in python/opsml/card/_card.pyi
get_metrics(names=None)
¶
Get metrics of an experiment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
list[str] | None
|
Names of the metrics to get. If None, all metrics will be returned. |
None
|
Returns:
Type | Description |
---|---|
Metrics
|
Metrics |
Source code in python/opsml/card/_card.pyi
get_parameters(names=None)
¶
Get parameters of an experiment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
names
|
list[str] | None
|
Names of the parameters to get. If None, all parameters will be returned. |
None
|
Returns:
Type | Description |
---|---|
Parameters
|
Parameters |
Source code in python/opsml/card/_card.pyi
list_artifacts(path)
¶
List the artifacts associated with the experiment card
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Specific path you wish to list artifacts from. If not provided, all artifacts will be listed. Example: You logged artifacts with the following paths: - "data/processed/my_data.csv" - "model/my_model.pkl"
|
required |
Source code in python/opsml/card/_card.pyi
model_validate_json(json_string)
staticmethod
¶
Load card from json string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string
|
str
|
The json string to validate |
required |
ModelCard
¶
Source code in python/opsml/card/_card.pyi
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
|
app_env
property
¶
Returns the app env
created_at
property
¶
Returns the created at timestamp
datacard_uid
property
writable
¶
Returns the datacard uid
drift_profile
property
¶
Return the drift profile map from the model interface.
Returns:
Type | Description |
---|---|
DriftProfileMap
|
DriftProfileMap |
experimentcard_uid
property
writable
¶
Returns the experimentcard uid
interface
property
writable
¶
Returns the ModelInterface
associated with the ModelCard
metadata
property
¶
Returns the metadata of the ModelCard
model
property
¶
Returns the model. This is a special property that is used to access the model from the interface. It is not settable. It will also raise an error if the interface is not set or if the model has not been loaded.
name
property
writable
¶
Returns the name of the ModelCard
onnx_session
property
¶
Returns the onnx session. This is a special property that is used to access the onnx session from the interface. It is not settable. It will also raise an error if the interface is not set or if the model has not been loaded.
registry_type
property
¶
Returns the card type of the ModelCard
space
property
writable
¶
Returns the space of the ModelCard
tags
property
¶
Returns the tags of the ModelCard
uid
property
¶
Returns the uid of the ModelCard
uri
property
¶
Returns the uri of the ModelCard
in the
format of {registry}/{space}/{name}/v{version}
version
property
writable
¶
Returns the version of the ModelCard
__init__(interface=None, space=None, name=None, version=None, uid=None, tags=[], datacard_uid=None, metadata=ModelCardMetadata())
¶
Create a ModelCard from a machine learning model.
Cards are stored in the ModelCardRegistry and follow the naming convention of: {registry}/{space}/{name}/v{version}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interface
|
ModelInterface | None
|
|
None
|
space
|
str | None
|
space to associate with |
None
|
name
|
str | None
|
Name to associate with |
None
|
version
|
str | None
|
Current version (assigned if card has been registered). Follows semantic versioning. |
None
|
uid
|
str | None
|
Unique id (assigned if card has been registered) |
None
|
tags
|
List[str]
|
Tags to associate with |
[]
|
datacard_uid
|
str | None
|
The datacard uid to associate with the model card. This is used to link the model card to the data card. Datacard uid can also be set in card metadata. |
None
|
metadata
|
ModelCardMetadata
|
Metadata to associate with the |
ModelCardMetadata()
|
Example:
from opsml import ModelCard, CardRegistry, RegistryType, SklearnModel, TaskType
from sklearn import ensemble
# for testing purposes
from opsml.helpers.data import create_fake_data
# pandas data
X, y = create_fake_data(n_samples=1200)
# train model
reg = ensemble.RandomForestClassifier(n_estimators=5)
reg.fit(X_train.to_numpy(), y_train)
# create interface and card
interface = SklearnModel(
model=reg,
sample_data=X_train,
task_type=TaskType.Classification,
)
modelcard = ModelCard(
interface=random_forest_classifier,
space="my-repo",
name="my-model",
tags=["foo:bar", "baz:qux"],
)
# register card
registry = CardRegistry(RegistryType.Model, save_kwargs=ModelSaveKwargs(save_onnx=True)) # convert to onnx
registry.register_card(modelcard)
Source code in python/opsml/card/_card.pyi
__str__()
¶
Return a string representation of the ModelCard.
Returns:
Type | Description |
---|---|
str
|
String representation of the ModelCard. |
download_artifacts(path=None)
¶
Download artifacts associated with the ModelCard
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to save the artifacts. If not provided, the artifacts will be saved to a directory called "card_artifacts" |
None
|
Source code in python/opsml/card/_card.pyi
drift_profile_path(alias)
¶
Helper method that returns the path to a specific drift profile. This method will fail if there is no drift profile map or the alias does not exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alias
|
str
|
The alias of the drift profile |
required |
Returns:
Type | Description |
---|---|
Path
|
Path to the drift profile |
Source code in python/opsml/card/_card.pyi
load(path=None, load_kwargs=None)
¶
Load ModelCard interface components
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path | None
|
The path to load the data card from. If no path is provided, the model interface will be loaded from the server. |
None
|
load_kwargs
|
ModelLoadKwargs
|
Optional kwargs to pass to |
None
|
Source code in python/opsml/card/_card.pyi
model_dump_json()
¶
model_validate_json(json_string, interface=None)
staticmethod
¶
Validate the model json string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string
|
str
|
The json string to validate |
required |
interface
|
ModelInterface
|
By default, the interface will be inferred and instantiated from the interface metadata. If an interface is provided (as in the case of custom interfaces), it will be used. |
None
|
Source code in python/opsml/card/_card.pyi
save(path, save_kwargs=None)
¶
Save the model card to a directory
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to save the model card. |
required |
save_kwargs
|
SaveKwargs
|
Optional kwargs to pass to |
None
|
Source code in python/opsml/card/_card.pyi
ModelCardMetadata
¶
Source code in python/opsml/card/_card.pyi
auditcard_uid
property
writable
¶
Returns the experimentcard uid
datacard_uid
property
writable
¶
Returns the datacard uid
experimentcard_uid
property
writable
¶
Returns the experimentcard uid
__init__(datacard_uid=None, experimentcard_uid=None, auditcard_uid=None)
¶
Create a ModelCardMetadata object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datacard_uid
|
str | None
|
The datacard uid |
None
|
experimentcard_uid
|
str | None
|
The experimentcard uid |
None
|
auditcard_uid
|
str | None
|
The auditcard uid |
None
|
Source code in python/opsml/card/_card.pyi
PromptCard
¶
Source code in python/opsml/card/_card.pyi
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 |
|
experimentcard_uid
property
writable
¶
Returns the experimentcard uid
name
property
writable
¶
Returns the name of the ModelCard
prompt
property
writable
¶
Returns the prompt
space
property
writable
¶
Returns the space of the ModelCard
tags
property
¶
Returns the tags of the ModelCard
uid
property
¶
Returns the uid of the ModelCard
version
property
writable
¶
Returns the version of the ModelCard
__init__(prompt, space=None, name=None, version=None, uid=None, tags=[])
¶
Creates a PromptCard
.
Cards are stored in the PromptCard Registry and follow the naming convention of: {registry}/{space}/{name}/v{version}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
Prompt
|
Prompt to associate with |
required |
space
|
str | None
|
space to associate with |
None
|
name
|
str | None
|
Name to associate with |
None
|
version
|
str | None
|
Current version (assigned if card has been registered). Follows semantic versioning. |
None
|
uid
|
str | None
|
Unique id (assigned if card has been registered) |
None
|
tags
|
List[str]
|
Tags to associate with |
[]
|
Example:
from opsml import Prompt, PromptCard, CardRegistry, RegistryType
# create prompt
prompt = Prompt(
model="openai:gpt-4o",
user_message=[
"My prompt $1 is $2",
"My prompt $3 is $4",
],
system_message="system_prompt",
)
# create card
card = PromptCard(
prompt=prompt,
space="my-repo",
name="my-prompt",
version="0.0.1",
tags=["gpt-4o", "prompt"],
)
# register card
registry = CardRegistry(RegistryType.Prompt)
registry.register_card(card)
Source code in python/opsml/card/_card.pyi
model_validate_json(json_string)
staticmethod
¶
Load card from json string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_string
|
str
|
The json string to validate |
required |
save(path)
¶
Save the PromptCard
to a directory
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to save the prompt card. |
required |