From 3c4495091ac23ede7919df4d610e764cdd78389b Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 20 Aug 2021 14:36:23 -0400 Subject: [PATCH] fix: resolve issue importing library (#64) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #63 🦕 --- .../configmanagement_v1/services.rst | 0 .../configmanagement_v1/types.rst | 2 +- .../multiclusteringress_v1/services.rst | 0 .../multiclusteringress_v1/types.rst | 2 +- packages/google-cloud-gke-hub/docs/index.rst | 8 +-- .../configmanagement_v1/__init__.py | 0 .../configmanagement_v1/gapic_metadata.json | 0 .../configmanagement_v1/py.typed | 0 .../configmanagement_v1/services/__init__.py | 0 .../configmanagement_v1/types/__init__.py | 0 .../types/configmanagement.py | 0 .../multiclusteringress_v1/__init__.py | 0 .../gapic_metadata.json | 0 .../multiclusteringress_v1/py.typed | 0 .../services/__init__.py | 0 .../multiclusteringress_v1/types/__init__.py | 0 .../types/multiclusteringress.py | 0 .../google/cloud/gkehub_v1/types/feature.py | 16 +++--- packages/google-cloud-gke-hub/owlbot.py | 49 ++++++++++++++++--- .../unit/gapic/gkehub_v1/test_gke_hub.py | 4 +- 20 files changed, 58 insertions(+), 23 deletions(-) rename packages/google-cloud-gke-hub/docs/{ => gkehub_v1}/configmanagement_v1/services.rst (100%) rename packages/google-cloud-gke-hub/docs/{ => gkehub_v1}/configmanagement_v1/types.rst (71%) rename packages/google-cloud-gke-hub/docs/{ => gkehub_v1}/multiclusteringress_v1/services.rst (100%) rename packages/google-cloud-gke-hub/docs/{ => gkehub_v1}/multiclusteringress_v1/types.rst (71%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/configmanagement_v1/__init__.py (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/configmanagement_v1/gapic_metadata.json (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/configmanagement_v1/py.typed (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/configmanagement_v1/services/__init__.py (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/configmanagement_v1/types/__init__.py (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/configmanagement_v1/types/configmanagement.py (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/multiclusteringress_v1/__init__.py (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/multiclusteringress_v1/gapic_metadata.json (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/multiclusteringress_v1/py.typed (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/multiclusteringress_v1/services/__init__.py (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/multiclusteringress_v1/types/__init__.py (100%) rename packages/google-cloud-gke-hub/google/cloud/{gkehub => gkehub_v1}/multiclusteringress_v1/types/multiclusteringress.py (100%) diff --git a/packages/google-cloud-gke-hub/docs/configmanagement_v1/services.rst b/packages/google-cloud-gke-hub/docs/gkehub_v1/configmanagement_v1/services.rst similarity index 100% rename from packages/google-cloud-gke-hub/docs/configmanagement_v1/services.rst rename to packages/google-cloud-gke-hub/docs/gkehub_v1/configmanagement_v1/services.rst diff --git a/packages/google-cloud-gke-hub/docs/configmanagement_v1/types.rst b/packages/google-cloud-gke-hub/docs/gkehub_v1/configmanagement_v1/types.rst similarity index 71% rename from packages/google-cloud-gke-hub/docs/configmanagement_v1/types.rst rename to packages/google-cloud-gke-hub/docs/gkehub_v1/configmanagement_v1/types.rst index a002aa5d80ab..b2cb5fe9baaf 100644 --- a/packages/google-cloud-gke-hub/docs/configmanagement_v1/types.rst +++ b/packages/google-cloud-gke-hub/docs/gkehub_v1/configmanagement_v1/types.rst @@ -1,7 +1,7 @@ Types for Google Cloud Gkehub Configmanagement v1 API ===================================================== -.. automodule:: google.cloud.gkehub.configmanagement_v1.types +.. automodule:: google.cloud.gkehub_v1.configmanagement_v1.types :members: :undoc-members: :show-inheritance: diff --git a/packages/google-cloud-gke-hub/docs/multiclusteringress_v1/services.rst b/packages/google-cloud-gke-hub/docs/gkehub_v1/multiclusteringress_v1/services.rst similarity index 100% rename from packages/google-cloud-gke-hub/docs/multiclusteringress_v1/services.rst rename to packages/google-cloud-gke-hub/docs/gkehub_v1/multiclusteringress_v1/services.rst diff --git a/packages/google-cloud-gke-hub/docs/multiclusteringress_v1/types.rst b/packages/google-cloud-gke-hub/docs/gkehub_v1/multiclusteringress_v1/types.rst similarity index 71% rename from packages/google-cloud-gke-hub/docs/multiclusteringress_v1/types.rst rename to packages/google-cloud-gke-hub/docs/gkehub_v1/multiclusteringress_v1/types.rst index 03d088d35612..c6161e6f5615 100644 --- a/packages/google-cloud-gke-hub/docs/multiclusteringress_v1/types.rst +++ b/packages/google-cloud-gke-hub/docs/gkehub_v1/multiclusteringress_v1/types.rst @@ -1,7 +1,7 @@ Types for Google Cloud Gkehub Multiclusteringress v1 API ======================================================== -.. automodule:: google.cloud.gkehub.multiclusteringress_v1.types +.. automodule:: google.cloud.gkehub_v1.multiclusteringress_v1.types :members: :undoc-members: :show-inheritance: diff --git a/packages/google-cloud-gke-hub/docs/index.rst b/packages/google-cloud-gke-hub/docs/index.rst index 58d3d03c4758..ccb280875d6c 100644 --- a/packages/google-cloud-gke-hub/docs/index.rst +++ b/packages/google-cloud-gke-hub/docs/index.rst @@ -9,10 +9,10 @@ API Reference gkehub_v1/services gkehub_v1/types - configmanagement_v1/services - configmanagement_v1/types - multiclusteringress_v1/services - multiclusteringress_v1/types + gkehub_v1/configmanagement_v1/services + gkehub_v1/configmanagement_v1/types + gkehub_v1/multiclusteringress_v1/services + gkehub_v1/multiclusteringress_v1/types API Reference ------------- diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/__init__.py b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/__init__.py similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/__init__.py rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/__init__.py diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/gapic_metadata.json b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/gapic_metadata.json similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/gapic_metadata.json rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/gapic_metadata.json diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/py.typed b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/py.typed similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/py.typed rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/py.typed diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/services/__init__.py b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/services/__init__.py similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/services/__init__.py rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/services/__init__.py diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/types/__init__.py b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/types/__init__.py similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/types/__init__.py rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/types/__init__.py diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/types/configmanagement.py similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/configmanagement_v1/types/configmanagement.py rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/configmanagement_v1/types/configmanagement.py diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/__init__.py b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/__init__.py similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/__init__.py rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/__init__.py diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/gapic_metadata.json similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/gapic_metadata.json rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/gapic_metadata.json diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/py.typed b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/py.typed similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/py.typed rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/py.typed diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/services/__init__.py b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/services/__init__.py similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/services/__init__.py rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/services/__init__.py diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/types/__init__.py similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/types/__init__.py rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/types/__init__.py diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/types/multiclusteringress.py similarity index 100% rename from packages/google-cloud-gke-hub/google/cloud/gkehub/multiclusteringress_v1/types/multiclusteringress.py rename to packages/google-cloud-gke-hub/google/cloud/gkehub_v1/multiclusteringress_v1/types/multiclusteringress.py diff --git a/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/types/feature.py b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/types/feature.py index 749a5882bdb7..f992f04368fc 100644 --- a/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/types/feature.py +++ b/packages/google-cloud-gke-hub/google/cloud/gkehub_v1/types/feature.py @@ -15,8 +15,8 @@ # import proto # type: ignore -from google.cloud.gkehub import configmanagement_v1 as configmanagement_pb2 # type: ignore -from google.cloud.gkehub import multiclusteringress_v1 as multiclusteringress_pb2 # type: ignore +from google.cloud.gkehub_v1 import configmanagement_v1 # type: ignore +from google.cloud.gkehub_v1 import multiclusteringress_v1 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -175,7 +175,7 @@ class CommonFeatureSpec(proto.Message): r"""CommonFeatureSpec contains Hub-wide configuration informatio. Attributes: - multiclusteringress (google.cloud.gkehub.multiclusteringress.v1.multiclusteringress_pb2.FeatureSpec): + multiclusteringress (google.cloud.gkehub_v1.multiclusteringress_v1.FeatureSpec): Multicluster Ingress-specific spec. """ @@ -183,7 +183,7 @@ class CommonFeatureSpec(proto.Message): proto.MESSAGE, number=102, oneof="feature_spec", - message=multiclusteringress_pb2.FeatureSpec, + message=multiclusteringress_v1.FeatureSpec, ) @@ -205,7 +205,7 @@ class MembershipFeatureSpec(proto.Message): a single Membership. Attributes: - configmanagement (google.cloud.gkehub.configmanagement.v1.configmanagement_pb2.MembershipSpec): + configmanagement (google.cloud.gkehub_v1.configmanagement_v1.MembershipSpec): Config Management-specific spec. """ @@ -213,7 +213,7 @@ class MembershipFeatureSpec(proto.Message): proto.MESSAGE, number=106, oneof="feature_spec", - message=configmanagement_pb2.MembershipSpec, + message=configmanagement_v1.MembershipSpec, ) @@ -222,7 +222,7 @@ class MembershipFeatureState(proto.Message): for a single Membership. Attributes: - configmanagement (google.cloud.gkehub.configmanagement.v1.configmanagement_pb2.MembershipState): + configmanagement (google.cloud.gkehub_v1.configmanagement_v1.MembershipState): Config Management-specific state. state (google.cloud.gkehub_v1.types.FeatureState): The high-level state of this Feature for a @@ -233,7 +233,7 @@ class MembershipFeatureState(proto.Message): proto.MESSAGE, number=106, oneof="feature_state", - message=configmanagement_pb2.MembershipState, + message=configmanagement_v1.MembershipState, ) state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",) diff --git a/packages/google-cloud-gke-hub/owlbot.py b/packages/google-cloud-gke-hub/owlbot.py index 11d0487a01fb..0a23467a7ab1 100644 --- a/packages/google-cloud-gke-hub/owlbot.py +++ b/packages/google-cloud-gke-hub/owlbot.py @@ -25,21 +25,45 @@ default_version = "v1" for library in s.get_staging_dirs(default_version): - dependencies = [ + submodules = [ "configmanagement", "multiclusteringress", ] - # rename dependencies google.cloud.gkehub.dep.vX to google.cloud.gkehub.dep_vX - for dep in dependencies: + for submodule in submodules: + # Move v1 submodule namespace from google.cloud.gkehub.{submodule}_v1 to google.cloud.gkehub_vX.{submodule}_v1 + s.move(library / f"google/cloud/gkehub/{submodule}_v1", library / f"google/cloud/gkehub_{library.name}/{submodule}_v1") + + # Adjust docs based on new submodule namespace google.cloud.gkehub_vX.{submodule}_v1.types" + s.replace( + library / f"docs/{submodule}_v1/types.rst", + f"google.cloud.gkehub.{submodule}_v1.types", + f"google.cloud.gkehub_{library.name}.{submodule}_v1.types", + ) + + # Move docs to correct location /docs/gkehub_vX/{submodule}_v1 + s.move(library / f"docs/{submodule}_v1", library / f"docs/gkehub_{library.name}/{submodule}_v1") + + # Rename v1 submodule imports from google.cloud.gkehub.submodule.v1 to google.cloud.gkehub_vX.submodule_v1 s.replace( [ library / f"google/cloud/gkehub_{library.name}/**/*.py", library / f"tests/unit/gapic/gkehub_{library.name}/**/*.py", - library / f"google/cloud/gkehub/{dep}_{library.name}/**/*.py", ], - f"from google.cloud.gkehub.{dep}.{library.name} import", - f"from google.cloud.gkehub import {dep}_{library.name} as" + f"from google.cloud.gkehub.{submodule}.v1 import {submodule}_pb2", + f"from google.cloud.gkehub_{library.name} import {submodule}_v1" + ) + + s.replace( + library / f"google/cloud/gkehub_{library.name}/types/feature.py", + f"google.cloud.gkehub.{submodule}.v1.{submodule}_pb2", + f"google.cloud.gkehub_v1.{submodule}_v1" + ) + + s.replace( + library / f"google/cloud/gkehub_{library.name}/types/feature.py", + f"{submodule}_pb2", + f"{submodule}_v1" ) # Work around gapic generator bug https://github.com/googleapis/gapic-generator-python/issues/902 @@ -64,7 +88,18 @@ //container.googleapis.com/projects/my-""" ) - s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst", "google/cloud/gkehub/configmanagement", "google/cloud/gkehub/multiclusteringress"]) + excludes=[ + "setup.py", + "README.rst", + "docs/index.rst", + "docs/configmanagement_v1/**", + "docs/multiclusteringress_v1/**", + "google/cloud/gkehub/configmanagement/**", + "google/cloud/gkehub/configmanagement_v1/**", + "google/cloud/gkehub/multiclusteringress/**", + "google/cloud/gkehub/multiclusteringress_v1/**" + ] + s.move(library, excludes=excludes) s.remove_staging_dirs() diff --git a/packages/google-cloud-gke-hub/tests/unit/gapic/gkehub_v1/test_gke_hub.py b/packages/google-cloud-gke-hub/tests/unit/gapic/gkehub_v1/test_gke_hub.py index e2e15fa2fc74..69f3bdc6663c 100644 --- a/packages/google-cloud-gke-hub/tests/unit/gapic/gkehub_v1/test_gke_hub.py +++ b/packages/google-cloud-gke-hub/tests/unit/gapic/gkehub_v1/test_gke_hub.py @@ -34,8 +34,8 @@ from google.api_core import operations_v1 from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.gkehub import configmanagement_v1 as configmanagement_pb2 # type: ignore -from google.cloud.gkehub import multiclusteringress_v1 as multiclusteringress_pb2 # type: ignore +from google.cloud.gkehub_v1 import configmanagement_v1 # type: ignore +from google.cloud.gkehub_v1 import multiclusteringress_v1 # type: ignore from google.cloud.gkehub_v1.services.gke_hub import GkeHubAsyncClient from google.cloud.gkehub_v1.services.gke_hub import GkeHubClient from google.cloud.gkehub_v1.services.gke_hub import pagers