Skip to content

Commit

Permalink
revert exluded files
Browse files Browse the repository at this point in the history
  • Loading branch information
dizcology committed Sep 7, 2023
1 parent c48aa5e commit 19d7edc
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.10/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env_vars: {
# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-310"
value: "ucaip-sample-tests"
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.11/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env_vars: {
# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-311"
value: "ucaip-sample-tests"
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.7/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env_vars: {
# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-py37"
value: "ucaip-sample-tests"
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.7/periodic.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
value: "True"
}
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.8/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env_vars: {
# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-py38"
value: "ucaip-sample-tests"
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.9/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env_vars: {
# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-py39"
value: "ucaip-sample-tests"
}

env_vars: {
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ repos:
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
rev: 6.1.0
hooks:
- id: flake8
54 changes: 54 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,57 @@
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True


def adopt_members_reexported_from_private_modules(public_module: str):
"""Remaps the module items that come from internal modules.
A public module might be exporting items that are imported from private modules.
This function changes the `__module__` of such items to the public module.
Example:
`package/public.py`:
```
from package._private import _PrivateClass as PublicClass
__all__ = ["PublicClass"]
```
Calling this function on the `package.public` module will change:
```
package._private._PrivateClass.__name__ = "PublicClass"
package._private._PrivateClass.__module__ = "package.public"
```
"""
for name, cls in public_module.__dict__.items():
if name in public_module.__all__:
if "._" in cls.__module__:
cls.__name__ = name
cls.__module__ = public_module.__name__


def setup(*args, **kwargs):
# 1. Giving pretty module names to the GA and preview classes
# 2. Giving pretty class names to the preview classes
# 3. Making Sphinx automodule render the class members instead of
# dismissing the exported private classes as "Alias of".
from vertexai import language_models
from vertexai import vision_models
from vertexai.preview import (
language_models as preview_language_models,
)
from vertexai.preview import (
vision_models as preview_vision_models,
)

# There are many possible ways to select which classes to fix.
# We select the publicly exported members that have an internal module ("*._*").

# Setting the modules of the GA classes
adopt_members_reexported_from_private_modules(language_models)
adopt_members_reexported_from_private_modules(vision_models)

# Setting the modules of the public preview classes
# Selecting the members that still have an internal module after the GA fixes.
adopt_members_reexported_from_private_modules(preview_language_models)
adopt_members_reexported_from_private_modules(preview_vision_models)
6 changes: 4 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import nox

FLAKE8_VERSION = "flake8==6.1.0"
BLACK_VERSION = "black==22.3.0"
ISORT_VERSION = "isort==5.10.1"
LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
Expand All @@ -47,7 +48,7 @@
]
UNIT_TEST_EXTRAS_BY_PYTHON = {}

SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"]
SYSTEM_TEST_PYTHON_VERSIONS = ["3.11"]
SYSTEM_TEST_STANDARD_DEPENDENCIES = [
"mock",
"pytest",
Expand Down Expand Up @@ -85,10 +86,11 @@ def lint(session):
Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.install("flake8", BLACK_VERSION)
session.install(FLAKE8_VERSION, BLACK_VERSION)
session.run(
"black",
"--check",
"--diff",
*LINT_PATHS,
)
session.run("flake8", "google", "tests")
Expand Down

0 comments on commit 19d7edc

Please sign in to comment.