Skip to content

Commit 339b0cb

Browse files
Ci lint (#338)
* setup pre-commit * add error codes * precommit run * fix build
1 parent f5f5aca commit 339b0cb

File tree

121 files changed

+46417
-41006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+46417
-41006
lines changed

.github/workflows/ci-lint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4.1.7
13+
with:
14+
# Ensure the full history is fetched
15+
# This is required to run pre-commit on a specific set of commits
16+
# TODO: Remove this when all the pre-commit issues are fixed
17+
fetch-depth: 0
18+
- uses: actions/setup-python@v5.1.1
19+
with:
20+
python-version: 3.13
21+
- uses: pre-commit/action@v3.0.1

.github/workflows/ci-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
- name: Run unit tests
3737
shell: bash
3838
run: |
39-
pytest
39+
pytest

.github/workflows/wheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ jobs:
2020
python-version: '3.10'
2121

2222
- name: Install python dependencies
23-
run: pip install build twine
23+
run: pip install --upgrade pip build twine
2424

2525
- name: Build sdist and wheel
2626
run: |
27-
python -m build -o wheelhouse
27+
python -m build --sdist --wheel -o wheelhouse
2828
2929
- name: List and check sdist
3030
run: |

.pre-commit-config.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# pre-commit is a tool to perform a predefined set of tasks manually and/or
2+
# automatically before git commits are made.
3+
#
4+
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
5+
#
6+
# Common tasks
7+
#
8+
# - Register git hooks: pre-commit install --install-hooks
9+
# - Run on all files: pre-commit run --all-files
10+
#
11+
# These pre-commit hooks are run as CI.
12+
#
13+
# NOTE: if it can be avoided, add configs/args in pyproject.toml or below instead of creating a new `.config.file`.
14+
# https://pre-commit.ci/#configuration
15+
ci:
16+
autoupdate_schedule: monthly
17+
autofix_commit_msg: |
18+
[pre-commit.ci] Apply automatic pre-commit fixes
19+
20+
repos:
21+
# general
22+
- repo: https://github.com/pre-commit/pre-commit-hooks
23+
rev: v4.6.0
24+
hooks:
25+
- id: end-of-file-fixer
26+
exclude: '\.svg$'
27+
- id: trailing-whitespace
28+
exclude: '\.svg$'
29+
- id: check-json
30+
- id: check-yaml
31+
args: [--allow-multiple-documents, --unsafe]
32+
- id: check-toml
33+
34+
- repo: https://github.com/astral-sh/ruff-pre-commit
35+
rev: v0.5.6
36+
hooks:
37+
- id: ruff
38+
args: ["--fix"]
39+
- id: ruff-format

RELEASE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
* Enable passing `tf.saved_model.SaveOptions` to model saving functionality.
6868
* Census and sentiment examples updated to only use Keras instead of
6969
estimator.
70-
* Depends on `apache-beam[gcp]>=2.53.0,<3` for Python 3.11 and on
70+
* Depends on `apache-beam[gcp]>=2.53.0,<3` for Python 3.11 and on
7171
`apache-beam[gcp]>=2.47.0,<3` for 3.9 and 3.10.
7272
* Depends on `protobuf>=4.25.2,<5` for Python 3.11 and on `protobuf>3.20.3,<5`
7373
for 3.9 and 3.10.
@@ -1535,4 +1535,3 @@ the generated vocab_filename on a downstream component.
15351535
* Update tensorflow_transform to use `tf.saved_model` APIs.
15361536
* Add default values on example proto coder.
15371537
* Various performance and stability improvements.
1538-

docs/build_tft_beam_docs.py

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,51 +25,53 @@
2525
```
2626
2727
"""
28-
from absl import app
29-
from absl import flags
3028

31-
from tensorflow_docs.api_generator import doc_controls
32-
from tensorflow_docs.api_generator import generate_lib
33-
from tensorflow_docs.api_generator import public_api
34-
import tensorflow_transform.beam as tft_beam
29+
from absl import app, flags
30+
from tensorflow_docs.api_generator import doc_controls, generate_lib, public_api
3531

32+
import tensorflow_transform.beam as tft_beam
3633

37-
flags.DEFINE_string('output_dir', '/tmp/tft_beam_api/',
38-
'The path to output the files to')
34+
flags.DEFINE_string(
35+
"output_dir", "/tmp/tft_beam_api/", "The path to output the files to"
36+
)
3937

4038
flags.DEFINE_string(
41-
'code_url_prefix',
42-
'https://github.com/tensorflow/transform/tree/master/tensorflow_transform',
43-
'The url prefix for links to code.')
39+
"code_url_prefix",
40+
"https://github.com/tensorflow/transform/tree/master/tensorflow_transform",
41+
"The url prefix for links to code.",
42+
)
4443

45-
flags.DEFINE_bool('search_hints', True,
46-
'Include metadata search hints in the generated files')
44+
flags.DEFINE_bool(
45+
"search_hints", True, "Include metadata search hints in the generated files"
46+
)
4747

48-
flags.DEFINE_string('site_path', 'tfx/transform/api_docs/python',
49-
'Path prefix in the _toc.yaml')
48+
flags.DEFINE_string(
49+
"site_path", "tfx/transform/api_docs/python", "Path prefix in the _toc.yaml"
50+
)
5051

5152
FLAGS = flags.FLAGS
5253

5354

5455
def main(args):
55-
if args[1:]:
56-
raise ValueError('Unrecognized Command line args', args[1:])
56+
if args[1:]:
57+
raise ValueError("Unrecognized Command line args", args[1:])
5758

58-
doc_controls.do_not_generate_docs(tft_beam.analyzer_impls)
59+
doc_controls.do_not_generate_docs(tft_beam.analyzer_impls)
5960

60-
doc_generator = generate_lib.DocGenerator(
61-
root_title='TFT-Beam',
62-
py_modules=[('tft_beam', tft_beam)],
63-
code_url_prefix=FLAGS.code_url_prefix + '/beam',
64-
search_hints=FLAGS.search_hints,
65-
site_path=FLAGS.site_path,
66-
callbacks=[
67-
public_api.explicit_package_contents_filter,
68-
public_api.local_definitions_filter
69-
])
61+
doc_generator = generate_lib.DocGenerator(
62+
root_title="TFT-Beam",
63+
py_modules=[("tft_beam", tft_beam)],
64+
code_url_prefix=FLAGS.code_url_prefix + "/beam",
65+
search_hints=FLAGS.search_hints,
66+
site_path=FLAGS.site_path,
67+
callbacks=[
68+
public_api.explicit_package_contents_filter,
69+
public_api.local_definitions_filter,
70+
],
71+
)
7072

71-
doc_generator.build(FLAGS.output_dir)
73+
doc_generator.build(FLAGS.output_dir)
7274

7375

74-
if __name__ == '__main__':
75-
app.run(main)
76+
if __name__ == "__main__":
77+
app.run(main)

docs/build_tft_docs.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,45 +25,46 @@
2525
```
2626
2727
"""
28-
from absl import app
29-
from absl import flags
3028

31-
from tensorflow_docs.api_generator import generate_lib
32-
from tensorflow_docs.api_generator import public_api
33-
import tensorflow_transform as transform
29+
from absl import app, flags
30+
from tensorflow_docs.api_generator import generate_lib, public_api
3431

32+
import tensorflow_transform as transform
3533

36-
flags.DEFINE_string('output_dir', '/tmp/tft_api/',
37-
'The path to output the files to')
34+
flags.DEFINE_string("output_dir", "/tmp/tft_api/", "The path to output the files to")
3835

3936
flags.DEFINE_string(
40-
'code_url_prefix',
41-
'https://github.com/tensorflow/transform/tree/master/tensorflow_transform',
42-
'The url prefix for links to code.')
37+
"code_url_prefix",
38+
"https://github.com/tensorflow/transform/tree/master/tensorflow_transform",
39+
"The url prefix for links to code.",
40+
)
4341

44-
flags.DEFINE_bool('search_hints', True,
45-
'Include metadata search hints in the generated files')
42+
flags.DEFINE_bool(
43+
"search_hints", True, "Include metadata search hints in the generated files"
44+
)
4645

47-
flags.DEFINE_string('site_path', 'tfx/transform/api_docs/python',
48-
'Path prefix in the _toc.yaml')
46+
flags.DEFINE_string(
47+
"site_path", "tfx/transform/api_docs/python", "Path prefix in the _toc.yaml"
48+
)
4949

5050
FLAGS = flags.FLAGS
5151

5252

5353
def main(args):
54-
if args[1:]:
55-
raise ValueError('Unrecognized Command line args', args[1:])
54+
if args[1:]:
55+
raise ValueError("Unrecognized Command line args", args[1:])
5656

57-
doc_generator = generate_lib.DocGenerator(
58-
root_title='TF-Transform',
59-
py_modules=[('tft', transform)],
60-
code_url_prefix=FLAGS.code_url_prefix,
61-
search_hints=FLAGS.search_hints,
62-
site_path=FLAGS.site_path,
63-
callbacks=[public_api.explicit_package_contents_filter])
57+
doc_generator = generate_lib.DocGenerator(
58+
root_title="TF-Transform",
59+
py_modules=[("tft", transform)],
60+
code_url_prefix=FLAGS.code_url_prefix,
61+
search_hints=FLAGS.search_hints,
62+
site_path=FLAGS.site_path,
63+
callbacks=[public_api.explicit_package_contents_filter],
64+
)
6465

65-
doc_generator.build(FLAGS.output_dir)
66+
doc_generator.build(FLAGS.output_dir)
6667

6768

68-
if __name__ == '__main__':
69-
app.run(main)
69+
if __name__ == "__main__":
70+
app.run(main)

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The [`tft`](api_docs/python/tft)
1111
module documentation is the only module that is relevant to TFX users.
1212
The [`tft_beam`](api_docs/python/tft-beam)
1313
module is relevant only when using Transform as a standalone library.
14-
Typically, a TFX user constructs a `preprocessing_fn`, and the rest of the
14+
Typically, a TFX user constructs a `preprocessing_fn`, and the rest of the
1515
Transform library calls are made by the Transform component.
1616

1717
You can also use the Apache Beam `MLTransform`

docs/javascripts/mathjax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ window.MathJax = {
1111
}
1212
};
1313

14-
document$.subscribe(() => {
14+
document$.subscribe(() => {
1515
MathJax.startup.output.clearCache()
1616
MathJax.typesetClear()
1717
MathJax.texReset()

0 commit comments

Comments
 (0)