Skip to content

Commit

Permalink
remove a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeWang1127 committed May 16, 2024
1 parent c4731d1 commit 7385de4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
5 changes: 0 additions & 5 deletions library_generation/generate_composed_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ def generate_composed_library(
library: LibraryConfig,
output_folder: str,
versions_file: str,
gapic_repo: bool,
) -> None:
"""
Generate libraries composed of more than one service or service version
:param has_proto_only_libraries:
:param config_path: Path to generation configuration.
:param config: a GenerationConfig object representing a parsed configuration
yaml
Expand All @@ -61,8 +59,6 @@ def generate_composed_library(
for convenience and to prevent all libraries to be processed
:param output_folder: the folder to where tools go
:param versions_file: the file containing version of libraries
:param gapic_repo: whether the library is generated into a gapic
repository or not.
:return None
"""
util.pull_api_definition(
Expand All @@ -85,7 +81,6 @@ def generate_composed_library(
proto_path=util.remove_version_from(gapic.proto_path),
transport=gapic_inputs.transport,
library_path=library_path,
gapic_repo=gapic_repo,
)
temp_destination_path = f"java-{gapic.proto_path.replace('/','-')}"
effective_arguments = __construct_effective_arg(
Expand Down
1 change: 0 additions & 1 deletion library_generation/generate_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def generate_from_yaml(
library=library,
output_folder=repo_config.output_folder,
versions_file=repo_config.versions_file,
gapic_repo=not config.contains_common_protos(),
)

if not config.is_monorepo() or config.contains_common_protos():
Expand Down
4 changes: 2 additions & 2 deletions library_generation/model/generation_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
REPO_LEVEL_PARAMETER = "Repo level parameter"
LIBRARY_LEVEL_PARAMETER = "Library level parameter"
GAPIC_LEVEL_PARAMETER = "GAPIC level parameter"
COMMON_PROTOS = "common-protos"
COMMON_PROTOS_LIBRARY_NAME = "common-protos"


class GenerationConfig:
Expand Down Expand Up @@ -69,7 +69,7 @@ def contains_common_protos(self) -> bool:
if self.__contains_common_protos is None:
self.__contains_common_protos = False
for library in self.libraries:
if library.get_library_name() == COMMON_PROTOS:
if library.get_library_name() == COMMON_PROTOS_LIBRARY_NAME:
self.__contains_common_protos = True
break
return self.__contains_common_protos
Expand Down
24 changes: 11 additions & 13 deletions library_generation/test/utilities_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@
api_description="allows you to encrypt, store, manage, and audit infrastructure and application-level secrets.",
gapic_configs=list(),
)
library_3 = LibraryConfig(
api_shortname="secret",
name_pretty="Secret Management Example",
product_documentation="https://cloud.google.com/solutions/",
api_description="allows you to encrypt, store, and audit infrastructure and application-level secrets.",
library_name="secretmanager",
common_protos = LibraryConfig(
api_shortname="common-protos",
name_pretty="Common Protos",
product_documentation="",
api_description="example description",
gapic_configs=list(),
)

Expand Down Expand Up @@ -206,7 +205,7 @@ def test_generate_prerequisite_files_monorepo_success(self):

def test_generate_prerequisite_files_proto_only_repo_success(self):
library_path = self.__setup_prerequisite_files(
combination=2, library_type="OTHER", gapic_repo=False
combination=3, library_type="OTHER"
)

file_comparator.compare_files(
Expand Down Expand Up @@ -262,7 +261,6 @@ def __setup_prerequisite_files(
combination: int,
library_type: str = "GAPIC_AUTO",
library: LibraryConfig = library_1,
gapic_repo: bool = True,
) -> str:
library_path = f"{resources_dir}/goldens"
files = [
Expand All @@ -271,6 +269,7 @@ def __setup_prerequisite_files(
f"{library_path}/owlbot.py",
]
cleanup(files)
library.library_type = library_type
config = self.__get_a_gen_config(combination, library_type=library_type)
proto_path = "google/cloud/baremetalsolution/v2"
transport = "grpc"
Expand All @@ -280,7 +279,6 @@ def __setup_prerequisite_files(
proto_path=proto_path,
transport=transport,
library_path=library_path,
gapic_repo=gapic_repo,
)
return library_path

Expand All @@ -296,12 +294,12 @@ def __get_a_gen_config(
the GenerationConfig. Only support 1, 2 or 3.
:return: an object of GenerationConfig
"""
if combination == 2:
if combination == 1:
libraries = [library_1]
elif combination == 2:
libraries = [library_1, library_2]
elif combination == 3:
libraries = [library_2, library_3]
else:
libraries = [library_1]
libraries = [library_1, common_protos]

# update libraries with custom configuration (for now, only
# library_type)
Expand Down
7 changes: 2 additions & 5 deletions library_generation/utils/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def generate_prerequisite_files(
proto_path: str,
transport: str,
library_path: str,
gapic_repo: bool,
language: str = "java",
) -> None:
"""
Expand All @@ -202,8 +201,6 @@ def generate_prerequisite_files(
:param proto_path: the proto path
:param transport: transport supported by the library
:param library_path: the path to which the generated file goes
:param gapic_repo: whether the library is generated into a gapic
repository or not.
:param language: programming language of the library
:return: None
"""
Expand All @@ -215,7 +212,7 @@ def generate_prerequisite_files(
else f"{library.group_id}:google-{cloud_prefix}{library_name}"
)
distribution_name_short = re.split(r"[:/]", distribution_name)[-1]
if not gapic_repo:
if config.contains_common_protos():
repo = "googleapis/sdk-platform-java"
elif config.is_monorepo():
repo = "googleapis/google-cloud-java"
Expand Down Expand Up @@ -255,7 +252,7 @@ def generate_prerequisite_files(
"library_type": library.library_type,
"requires_billing": library.requires_billing,
}
if not gapic_repo:
if config.contains_common_protos():
repo_metadata.pop("api_id")

if library.api_reference:
Expand Down

0 comments on commit 7385de4

Please sign in to comment.