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

Conversation

@codesue
Copy link
Contributor

@codesue codesue commented May 14, 2023

What does this pull request do?

This pull request creates a basic model-card-toolkit package that supports only core functionality and moves dependencies specific to using MCT with TensorFlow and MLMD to extras. Here, core functionality means creating ModelCard and ModelCardToolkit objects, only manually annotating graphics and performance metrics, and rendering and exporting the model card. In other words, the features needed to run the example notebooks. This change will enable faster installations for developers who aren't working with TensorFlow models and reduce potential dependency conflicts. It will also enable using MCT on Apple Sillicon machines, which are unable to install ml-metadata, tensorflow-data-validation, and other TensorFlow extended libraries.

What changed

New required dependencies

  • jinja2: rendering model card templates
  • jsonschema: validating JSON schema
  • matplotlib: graphics
  • protobuf: working with model card protos

pip list output

Package             Version    Editable project location
------------------- ---------- -------------------------------------------
attrs               23.1.0
contourpy           1.0.7
cycler              0.11.0
fonttools           4.39.4
importlib-resources 5.12.0
Jinja2              3.1.2
jsonschema          3.2.0
kiwisolver          1.4.4
MarkupSafe          2.1.2
matplotlib          3.7.1
model-card-toolkit  3.0.0.dev0 /Users/sue/workspace/mct/model-card-toolkit
numpy               1.24.3
packaging           23.1
Pillow              9.5.0
pip                 23.1.2
protobuf            3.20.3
pyparsing           3.0.9
pyrsistent          0.19.3
python-dateutil     2.8.2
setuptools          56.0.0
six                 1.16.0
zipp                3.15.0

New extras

  • docs: building documentation
  • examples: running documentation example scripts
  • tensorflow: TensorFlow utils
  • test: running tests
  • all: everything everywhere all at once except for the docs extra

Refactoring and other changes

  • Moves proto build script out of model_card_toolkit
  • Stops importing names that require tensorflow extra dependencies in dunder inits
  • Prefixes filenames with tf_ to make it explicit when utils are specific to TensorFlow
  • Moves TensorFlow specific tests in core_test.py to core_tf_test.py
  • Moves validation utils to JSON utils since they only validate JSON schema
  • Adds pytest options --ignore-requires-optional-deps and --fail-if-skipped for easier testing
  • Updates relevant documentation and workflows

Backwards incompatible changes to the API

The primary change is that utilities that require optional TensorFlow dependencies are in files prefixed with tf_.

Removed Replacement
TensorFlow utils in model_card_toolkit.utils.graphics model_card_toolkit.utils.tf_graphics
model_card_toolkit.utils.json_util model_card_toolkit.utils.json_utils
model_card_toolkit.utils.testdata.testdata_utils model_card_toolkit.utils.testdata.tf_testdata_utils
model_card_toolkit.utils.sources model_card_toolkit.utils.tf_sources
model_card_toolkit.utils.tfx_utils model_card_toolkit.utils.tf_utils
model_card_toolkit.utils.validation model_card_toolkit.utils.json_utils

Fixes #93

How did you test this change?

  • Installed the basic package (and tests) with pip install -e ".[test]" and ran model_card_toolkit --ignore-requires-optional-deps. Passing --ignore-requires-optional-deps tells pytest not to collect tests that require optional dependencies, based on their file pattern.
  • Installed the all-inclusive package with pip install -e ".[all]" and ran model_card_toolkit --fail-if-skipped. In general, tests are marked as skip if they require optional dependencies that aren't installed. Failing skipped tests let us catch when tests are skipped even though all optional dependencies are installed.
  • Installed the basic package and each extra individually.
  • Ran the example notebooks.

How did you document this change?

Docstrings and updates to README, contributing guide, and installation guide.

Before submitting

Before submitting a pull request, please be sure to do the following:

  • Read the How to Contribute guide if this is your first contribution.
  • Open an issue or discussion topic to discuss this change.
  • Write new tests if applicable.
  • Update documentation if applicable.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codesue
Copy link
Contributor Author

codesue commented May 14, 2023

CI passed in my repo for largely the same requirements list yesterday but pulled in tensorflow-data-validation-1.10.0 instead of trying tensorflow-data-validation-1.5.0 and older versions. One change is that I handn't included tensorflow-docs yet, which worked when tested locally on Python 3.8. Closing this for now to limit workflow runs.

@codesue codesue closed this May 14, 2023
@codesue codesue reopened this May 14, 2023
@codesue codesue marked this pull request as ready for review May 15, 2023 01:26
@codesue
Copy link
Contributor Author

codesue commented May 15, 2023

It turns out tensorflow-docs is not traditionally versioned (always set to 0.0.0-dev and pinned by commit hash) and recently went from having no restrictions on Python version to requiring Python 3.8 in this commit. I removed docs dependencies from the all extra since they're not required to run all tests.

Relatedly, should we bump the minimum required Python version in MCT to 3.8 since Python 3.7 reaches end of support in June?

@casassg
Copy link
Member

casassg commented May 20, 2023

regarding py 3.8 I would ensure first that tfx and all those drop it first

@codesue codesue merged commit 95ef1b3 into tensorflow:main May 20, 2023
@codesue codesue deleted the codesue/make-tf-deps-optional branch May 20, 2023 20:49
@codesue codesue mentioned this pull request May 20, 2023
4 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question on the list of dependencies

2 participants