Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Commit 64f7e9f

Browse files
shuklak13ml-fairness-infra-github
authored andcommitted
MCT 1.1 release: update TFX dependencies and update MLMD_Model_Card_Toolkit_Demo
PiperOrigin-RevId: 394550241
1 parent aeac57a commit 64f7e9f

File tree

13 files changed

+52
-44
lines changed

13 files changed

+52
-44
lines changed

RELEASE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<!-- mdlint off(HEADERS_TOO_MANY_H1) -->
22

3-
# Current Version (Still in Development)
3+
# Release 1.1.0
44

55
## Major Features and Improvements
66

77
## Bug fixes and other changes
88

9+
* Update TFX compatibility to TFX 1.2.
10+
* Fix bug where all datasets from MLMD were being compressed into one model_card.Dataset object.
11+
912
## Breaking changes and Deprecations
1013

1114
# Release 1.0.0

model_card_toolkit/documentation/examples/MLMD_Model_Card_Toolkit_Demo.ipynb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"outputs": [],
103103
"source": [
104104
"!pip install --upgrade pip==20.2\n",
105-
"!pip install \"tfx==0.26.0\"\n",
105+
"!pip install \"tfx==1.2.0\"\n",
106106
"!pip install model-card-toolkit"
107107
]
108108
},
@@ -151,7 +151,6 @@
151151
"from tfx.components import CsvExampleGen\n",
152152
"from tfx.components import Evaluator\n",
153153
"from tfx.components import Pusher\n",
154-
"from tfx.components import ResolverNode\n",
155154
"from tfx.components import SchemaGen\n",
156155
"from tfx.components import StatisticsGen\n",
157156
"from tfx.components import Trainer\n",
@@ -167,7 +166,6 @@
167166
"from tfx.types import Channel\n",
168167
"from tfx.types.standard_artifacts import Model\n",
169168
"from tfx.types.standard_artifacts import ModelBlessing\n",
170-
"from tfx.utils.dsl_utils import external_input\n",
171169
"\n",
172170
"import ml_metadata as mlmd"
173171
]
@@ -290,7 +288,7 @@
290288
"# `pipeline_root` and `metadata_connection_config` may be passed to\n",
291289
"# InteractiveContext. Calls to InteractiveContext are no-ops outside of the\n",
292290
"# notebook.\n",
293-
"context = InteractiveContext()"
291+
"context = InteractiveContext(pipeline_name=\"Census Income Classification Pipeline\")"
294292
]
295293
},
296294
{
@@ -322,7 +320,7 @@
322320
},
323321
"outputs": [],
324322
"source": [
325-
"example_gen = CsvExampleGen(input=external_input(_data_root))\n",
323+
"example_gen = CsvExampleGen(input_base=_data_root)\n",
326324
"context.run(example_gen)"
327325
]
328326
},
@@ -356,7 +354,7 @@
356354
"outputs": [],
357355
"source": [
358356
"# Get the URI of the output artifact representing the training examples, which is a directory\n",
359-
"train_uri = os.path.join(example_gen.outputs['examples'].get()[0].uri, 'train')\n",
357+
"train_uri = os.path.join(example_gen.outputs['examples'].get()[0].uri, 'Split-train')\n",
360358
"\n",
361359
"# Get the list of files in this directory (all compressed TFRecord files)\n",
362360
"tfrecord_filenames = [os.path.join(train_uri, name)\n",
@@ -1231,10 +1229,10 @@
12311229
"# different collections. \n",
12321230
"model_card.quantitative_analysis.graphics.collection = filter_graphs(\n",
12331231
" model_card.quantitative_analysis.graphics.collection, TARGET_EVAL_GRAPH_NAMES)\n",
1234-
"model_card.model_parameters.data.eval.graphics.collection = filter_graphs(\n",
1235-
" model_card.model_parameters.data.eval.graphics.collection, TARGET_DATASET_GRAPH_NAMES)\n",
1236-
"model_card.model_parameters.data.train.graphics.collection = filter_graphs(\n",
1237-
" model_card.model_parameters.data.train.graphics.collection, TARGET_DATASET_GRAPH_NAMES)"
1232+
"model_card.model_parameters.data[0].graphics.collection = filter_graphs(\n",
1233+
" model_card.model_parameters.data[0].graphics.collection, TARGET_DATASET_GRAPH_NAMES)\n",
1234+
"model_card.model_parameters.data[1].graphics.collection = filter_graphs(\n",
1235+
" model_card.model_parameters.data[1].graphics.collection, TARGET_DATASET_GRAPH_NAMES)"
12381236
]
12391237
},
12401238
{
@@ -1254,13 +1252,15 @@
12541252
},
12551253
"outputs": [],
12561254
"source": [
1257-
"model_card.model_parameters.data.train.graphics.description = (\n",
1255+
"model_card.model_parameters.data[0].name = 'train_set'\n",
1256+
"model_card.model_parameters.data[0].graphics.description = (\n",
12581257
" 'This section includes graphs displaying the class distribution for the '\n",
12591258
" '“Race” and “Sex” attributes in our training dataset. We chose to '\n",
12601259
" 'show these graphs in particular because we felt it was important that '\n",
12611260
" 'users see the class imbalance.'\n",
12621261
")\n",
1263-
"model_card.model_parameters.data.eval.graphics.description = (\n",
1262+
"model_card.model_parameters.data[1].name = 'eval_set'\n",
1263+
"model_card.model_parameters.data[1].graphics.description = (\n",
12641264
" 'Like the training set, we provide graphs showing the class distribution '\n",
12651265
" 'of the data we used to evaluate our model’s performance. '\n",
12661266
")\n",

model_card_toolkit/model_card_toolkit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ def _scaffold_model_card(self) -> ModelCard:
173173
graphics.annotate_eval_result_plots(model_card, eval_result)
174174

175175
for stats_artifact in stats_artifacts:
176-
train_stats = tfx_util.read_stats_proto(stats_artifact.uri, 'train')
177-
eval_stats = tfx_util.read_stats_proto(stats_artifact.uri, 'eval')
176+
train_stats = tfx_util.read_stats_proto(stats_artifact.uri,
177+
'Split-train')
178+
eval_stats = tfx_util.read_stats_proto(stats_artifact.uri, 'Split-eval')
178179
graphics.annotate_dataset_feature_statistics_plots(
179180
model_card, [train_stats, eval_stats])
180181
return model_card

model_card_toolkit/template/html/default_template.html.jinja

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
{% endmacro %}
4242
{% macro render_graphics(graphics) %}
4343
<div class="img-container">
44+
{% if graphics.description %}<p>{{ graphics.description }}</p>{% endif %}
4445
{% for graph in graphics %}
4546
<div class="img-item">
4647
<img src='data:image/jpeg;base64,{{ graph.image }}' alt='{{ graph.name }}' />
@@ -131,7 +132,7 @@
131132
<h2>Model Details</h2>
132133
{% if model_details.overview %}<h3>Overview</h3>
133134
{{ model_details.overview }}{% endif %}
134-
{% if model_details.version %}<h3>Version</h3>
135+
{% if model_details.version and model_details.version.name %}<h3>Version</h3>
135136
{{ render_if_exist('name', model_details.version.name) }}
136137
{{ render_if_exist('date', model_details.version.date) }}
137138
{{ render_if_exist('diff', model_details.version.diff) }}

0 commit comments

Comments
 (0)