diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..4b33fe18 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,52 @@ +name: Deploy docs +on: + workflow_dispatch: + push: + branches: + - 'master' + pull_request: +permissions: + contents: write +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Configure Git Credentials + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + if: (github.event_name != 'pull_request') + + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: '3.9' + cache: 'pip' + cache-dependency-path: | + setup.py + requirements-docs.txt + + - name: Save time for cache for mkdocs + run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + + - name: Caching + uses: actions/cache@v4 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + + - name: Install Dependencies + run: pip install -r requirements-docs.txt + + - name: Deploy to GitHub Pages + run: mkdocs gh-deploy --force + if: (github.event_name != 'pull_request') + + - name: Build docs to check for errors + run: mkdocs build + if: (github.event_name == 'pull_request') diff --git a/docs/api_docs/python/beam.md b/docs/api_docs/python/beam.md new file mode 100644 index 00000000..88a88351 --- /dev/null +++ b/docs/api_docs/python/beam.md @@ -0,0 +1,3 @@ +# TFX-BSL Public Beam + +::: tfx_bsl.public.beam diff --git a/docs/api_docs/python/tfxio.md b/docs/api_docs/python/tfxio.md new file mode 100644 index 00000000..f378508a --- /dev/null +++ b/docs/api_docs/python/tfxio.md @@ -0,0 +1,3 @@ +# TFX-BSL Public TFXIO + +::: tfx_bsl.public.tfxio diff --git a/docs/images/tf_full_color_primary_icon.svg b/docs/images/tf_full_color_primary_icon.svg new file mode 100644 index 00000000..3e724777 --- /dev/null +++ b/docs/images/tf_full_color_primary_icon.svg @@ -0,0 +1 @@ +FullColorPrimary Icon \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 120000 index 00000000..32d46ee8 --- /dev/null +++ b/docs/index.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/docs/javascripts/mathjax.js b/docs/javascripts/mathjax.js new file mode 100644 index 00000000..0be88e04 --- /dev/null +++ b/docs/javascripts/mathjax.js @@ -0,0 +1,19 @@ +window.MathJax = { + tex: { + inlineMath: [["\\(", "\\)"]], + displayMath: [["\\[", "\\]"]], + processEscapes: true, + processEnvironments: true + }, + options: { + ignoreHtmlClass: ".*|", + processHtmlClass: "arithmatex" + } +}; + +document$.subscribe(() => { + MathJax.startup.output.clearCache() + MathJax.typesetClear() + MathJax.texReset() + MathJax.typesetPromise() +}) diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css new file mode 100644 index 00000000..21c97aa9 --- /dev/null +++ b/docs/stylesheets/extra.css @@ -0,0 +1,42 @@ +:root { + --md-primary-fg-color: #FFA800; + --md-primary-fg-color--light: #CCCCCC; + --md-primary-fg-color--dark: #425066; +} + +.video-wrapper { + max-width: 240px; + display: flex; + flex-direction: row; +} +.video-wrapper > iframe { + width: 100%; + aspect-ratio: 16 / 9; +} + +.buttons-wrapper { + flex-wrap: wrap; + gap: 1em; + display: flex; + /* flex-grow: 1; */ + /* justify-content: center; */ + /* align-content: center; */ +} + +.buttons-wrapper > a { + justify-content: center; + align-content: center; + flex-wrap: nowrap; + /* gap: 1em; */ + align-items: center; + text-align: center; + flex: 1 1 30%; + display: flex; +} + +.md-button > .buttons-content { + align-items: center; + justify-content: center; + display: flex; + gap: 1em; +} diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..8b01265c --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,118 @@ +site_name: TFX Basic Shared Libraries +repo_name: "tfx-bsl" +repo_url: https://github.com/tensorflow/tfx-bsl + +theme: + logo: images/tf_full_color_primary_icon.svg + name: material + palette: + # Palette toggle for automatic mode + - media: "(prefers-color-scheme)" + primary: custom + accent: custom + toggle: + icon: material/brightness-auto + name: Switch to light mode + + # Palette toggle for light mode + - media: "(prefers-color-scheme: light)" + primary: custom + accent: custom + scheme: default + toggle: + icon: material/brightness-7 + name: Switch to dark mode + + # Palette toggle for dark mode + - media: "(prefers-color-scheme: dark)" + primary: custom + accent: custom + scheme: slate + toggle: + icon: material/brightness-4 + name: Switch to system preference + favicon: images/tf_full_color_primary_icon.svg + + features: + - content.code.copy + - content.code.select + - content.action.edit + +plugins: + - search + - autorefs + - mkdocstrings: + default_handler: python + handlers: + python: + options: + show_source: true + show_root_heading: true + unwrap_annotated: true + show_symbol_type_toc: true + show_if_no_docstring: true + show_symbol_type_heading: true + merge_init_into_class: true + show_signature_annotations: true + separate_signature: true + signature_crossrefs: true + group_by_category: true + show_category_heading: true + show_submodules: true + show_root_full_path: true + docstring_section_style: "spacy" + inherited_members: true + summary: false + filters: + - "!^_" + - "^__init__$" + - "^__call__$" + - "!^logger" + - "!^test_" + - "!_test$" + extensions: + - griffe_inherited_docstrings + import: + - https://docs.python.org/3/objects.inv + +extra_css: + - stylesheets/extra.css + +extra_javascript: + - javascripts/mathjax.js + - https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js + +markdown_extensions: + - admonition + - attr_list + - def_list + - tables + - toc: + permalink: true + - pymdownx.highlight: + anchor_linenums: true + linenums: false + line_spans: __span + pygments_lang_class: true + - pymdownx.inlinehilite + - pymdownx.snippets + - pymdownx.superfences + - pymdownx.arithmatex: + generic: true + - pymdownx.critic + - pymdownx.caret + - pymdownx.keys + - pymdownx.mark + - pymdownx.tilde + - md_in_html + - pymdownx.emoji: + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:material.extensions.emoji.to_svg +watch: + - tfx_bsl + +nav: + - Home: index.md + - API Docs: + - tfx_bsl.public.beam: api_docs/python/beam.md + - tfx_bsl.public.tfxio: api_docs/python/tfxio.md diff --git a/requirements-docs.txt b/requirements-docs.txt new file mode 100644 index 00000000..15b34146 --- /dev/null +++ b/requirements-docs.txt @@ -0,0 +1,6 @@ +mkdocs +mkdocs-material +mkdocstrings[python] +griffe-inherited-docstrings +mkdocs-autorefs +ruff diff --git a/setup.py b/setup.py index 7c3a20f8..30906f6e 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,7 @@ """Package Setup script for TFX BSL.""" import os +from pathlib import Path import platform import shutil import subprocess @@ -201,6 +202,16 @@ def select_constraint(default, nightly=None, git_master=None): git_master='@git+https://github.com/tensorflow/serving@master', ), ], + extras_require = { + "docs" : [ + req for req in Path("./requirements-docs.txt") + .expanduser() + .resolve() + .read_text() + .splitlines() + if req + ] + }, python_requires='>=3.9,<4', packages=find_packages(), include_package_data=True, diff --git a/tfx_bsl/public/beam/__init__.py b/tfx_bsl/public/beam/__init__.py index d2891347..f731f124 100644 --- a/tfx_bsl/public/beam/__init__.py +++ b/tfx_bsl/public/beam/__init__.py @@ -14,3 +14,7 @@ """Module level imports for tfx_bsl.beam.""" from tfx_bsl.public.beam.run_inference import RunInference + +__all__ = [ + "RunInference", +] diff --git a/tfx_bsl/public/tfxio/__init__.py b/tfx_bsl/public/tfxio/__init__.py index 6ba3903c..5cf3f5dc 100644 --- a/tfx_bsl/public/tfxio/__init__.py +++ b/tfx_bsl/public/tfxio/__init__.py @@ -33,3 +33,21 @@ from tfx_bsl.tfxio.tf_sequence_example_record import TFSequenceExampleBeamRecord from tfx_bsl.tfxio.tf_sequence_example_record import TFSequenceExampleRecord from tfx_bsl.tfxio.tfxio import TFXIO + + +__all__ = [ + "BeamRecordCsvTFXIO", + "CsvTFXIO", + "RecordBatchToExamplesEncoder", + "RecordBatchesOptions", + "TFExampleBeamRecord", + "TFExampleRecord", + "TFGraphRecordDecoder", + "TFSequenceExampleBeamRecord", + "TFSequenceExampleRecord", + "TFXIO", + "TensorAdapter", + "TensorAdapterConfig", + "TensorFlowDatasetOptions", + "TensorRepresentations", +] diff --git a/tfx_bsl/tfxio/__init__.py b/tfx_bsl/tfxio/__init__.py index 7e1a3af9..081810d9 100644 --- a/tfx_bsl/tfxio/__init__.py +++ b/tfx_bsl/tfxio/__init__.py @@ -14,5 +14,23 @@ """Package tfxio contains the implementation of Standardized TFX inputs. Design doc: -https://github.com/tensorflow/community/blob/master/rfcs/20191017-tfx-standardized-inputs.md +[https://github.com/tensorflow/community/blob/master/rfcs/20191017-tfx-standardized-inputs.md](https://github.com/tensorflow/community/blob/master/rfcs/20191017-tfx-standardized-inputs.md) """ + + +__all__ = [ + "BeamRecordCsvTFXIO", + "CsvTFXIO", + "RecordBatchToExamplesEncoder", + "RecordBatchesOptions", + "TFExampleBeamRecord", + "TFExampleRecord", + "TFGraphRecordDecoder", + "TFSequenceExampleBeamRecord", + "TFSequenceExampleRecord", + "TFXIO", + "TensorAdapter", + "TensorAdapterConfig", + "TensorFlowDatasetOptions", + "TensorRepresentations", +]