Skip to content

Ci lint #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: pre-commit

on:
pull_request:
push:
branches: [master]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.7
with:
# Ensure the full history is fetched
# This is required to run pre-commit on a specific set of commits
# TODO: Remove this when all the pre-commit issues are fixed
fetch-depth: 0
- uses: actions/setup-python@v5.1.1
with:
python-version: 3.13
- uses: pre-commit/action@v3.0.1
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# pre-commit is a tool to perform a predefined set of tasks manually and/or
# automatically before git commits are made.
#
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
#
# Common tasks
#
# - Register git hooks: pre-commit install --install-hooks
# - Run on all files: pre-commit run --all-files
#
# These pre-commit hooks are run as CI.
#
# NOTE: if it can be avoided, add configs/args in pyproject.toml or below instead of creating a new `.config.file`.
# https://pre-commit.ci/#configuration
ci:
autoupdate_schedule: monthly
autofix_commit_msg: |
[pre-commit.ci] Apply automatic pre-commit fixes

repos:
# general
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: end-of-file-fixer
exclude: '\.svg$'
- id: trailing-whitespace
exclude: '\.svg$'
- id: check-json
- id: check-yaml
args: [--allow-multiple-documents, --unsafe]
- id: check-toml

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
3 changes: 1 addition & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* Enable passing `tf.saved_model.SaveOptions` to model saving functionality.
* Census and sentiment examples updated to only use Keras instead of
estimator.
* Depends on `apache-beam[gcp]>=2.53.0,<3` for Python 3.11 and on
* Depends on `apache-beam[gcp]>=2.53.0,<3` for Python 3.11 and on
`apache-beam[gcp]>=2.47.0,<3` for 3.9 and 3.10.
* Depends on `protobuf>=4.25.2,<5` for Python 3.11 and on `protobuf>3.20.3,<5`
for 3.9 and 3.10.
Expand Down Expand Up @@ -1513,4 +1513,3 @@ the generated vocab_filename on a downstream component.
* Update tensorflow_transform to use `tf.saved_model` APIs.
* Add default values on example proto coder.
* Various performance and stability improvements.

64 changes: 33 additions & 31 deletions docs/build_tft_beam_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,51 +25,53 @@
```

"""
from absl import app
from absl import flags

from tensorflow_docs.api_generator import doc_controls
from tensorflow_docs.api_generator import generate_lib
from tensorflow_docs.api_generator import public_api
import tensorflow_transform.beam as tft_beam
from absl import app, flags
from tensorflow_docs.api_generator import doc_controls, generate_lib, public_api

import tensorflow_transform.beam as tft_beam

flags.DEFINE_string('output_dir', '/tmp/tft_beam_api/',
'The path to output the files to')
flags.DEFINE_string(
"output_dir", "/tmp/tft_beam_api/", "The path to output the files to"
)

flags.DEFINE_string(
'code_url_prefix',
'https://github.com/tensorflow/transform/tree/master/tensorflow_transform',
'The url prefix for links to code.')
"code_url_prefix",
"https://github.com/tensorflow/transform/tree/master/tensorflow_transform",
"The url prefix for links to code.",
)

flags.DEFINE_bool('search_hints', True,
'Include metadata search hints in the generated files')
flags.DEFINE_bool(
"search_hints", True, "Include metadata search hints in the generated files"
)

flags.DEFINE_string('site_path', 'tfx/transform/api_docs/python',
'Path prefix in the _toc.yaml')
flags.DEFINE_string(
"site_path", "tfx/transform/api_docs/python", "Path prefix in the _toc.yaml"
)

FLAGS = flags.FLAGS


def main(args):
if args[1:]:
raise ValueError('Unrecognized Command line args', args[1:])
if args[1:]:
raise ValueError("Unrecognized Command line args", args[1:])

doc_controls.do_not_generate_docs(tft_beam.analyzer_impls)
doc_controls.do_not_generate_docs(tft_beam.analyzer_impls)

doc_generator = generate_lib.DocGenerator(
root_title='TFT-Beam',
py_modules=[('tft_beam', tft_beam)],
code_url_prefix=FLAGS.code_url_prefix + '/beam',
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[
public_api.explicit_package_contents_filter,
public_api.local_definitions_filter
])
doc_generator = generate_lib.DocGenerator(
root_title="TFT-Beam",
py_modules=[("tft_beam", tft_beam)],
code_url_prefix=FLAGS.code_url_prefix + "/beam",
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[
public_api.explicit_package_contents_filter,
public_api.local_definitions_filter,
],
)

doc_generator.build(FLAGS.output_dir)
doc_generator.build(FLAGS.output_dir)


if __name__ == '__main__':
app.run(main)
if __name__ == "__main__":
app.run(main)
53 changes: 27 additions & 26 deletions docs/build_tft_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,46 @@
```

"""
from absl import app
from absl import flags

from tensorflow_docs.api_generator import generate_lib
from tensorflow_docs.api_generator import public_api
import tensorflow_transform as transform
from absl import app, flags
from tensorflow_docs.api_generator import generate_lib, public_api

import tensorflow_transform as transform

flags.DEFINE_string('output_dir', '/tmp/tft_api/',
'The path to output the files to')
flags.DEFINE_string("output_dir", "/tmp/tft_api/", "The path to output the files to")

flags.DEFINE_string(
'code_url_prefix',
'https://github.com/tensorflow/transform/tree/master/tensorflow_transform',
'The url prefix for links to code.')
"code_url_prefix",
"https://github.com/tensorflow/transform/tree/master/tensorflow_transform",
"The url prefix for links to code.",
)

flags.DEFINE_bool('search_hints', True,
'Include metadata search hints in the generated files')
flags.DEFINE_bool(
"search_hints", True, "Include metadata search hints in the generated files"
)

flags.DEFINE_string('site_path', 'tfx/transform/api_docs/python',
'Path prefix in the _toc.yaml')
flags.DEFINE_string(
"site_path", "tfx/transform/api_docs/python", "Path prefix in the _toc.yaml"
)

FLAGS = flags.FLAGS


def main(args):
if args[1:]:
raise ValueError('Unrecognized Command line args', args[1:])
if args[1:]:
raise ValueError("Unrecognized Command line args", args[1:])

doc_generator = generate_lib.DocGenerator(
root_title='TF-Transform',
py_modules=[('tft', transform)],
code_url_prefix=FLAGS.code_url_prefix,
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[public_api.explicit_package_contents_filter])
doc_generator = generate_lib.DocGenerator(
root_title="TF-Transform",
py_modules=[("tft", transform)],
code_url_prefix=FLAGS.code_url_prefix,
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[public_api.explicit_package_contents_filter],
)

doc_generator.build(FLAGS.output_dir)
doc_generator.build(FLAGS.output_dir)


if __name__ == '__main__':
app.run(main)
if __name__ == "__main__":
app.run(main)
Loading