Skip to content

Commit ed2cb46

Browse files
committed
Add --no-update-api-spec to neptune_api_codegen.cli
1 parent 18996ef commit ed2cb46

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

.github/workflows/tests-neptune-api-codegen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ jobs:
3737
- name: Run codegen and verify no changes
3838
run: |
3939
cd src &&
40-
python -m neptune_api_codegen.cli --update &&
40+
python -m neptune_api_codegen.cli --no-update-api-spec --update &&
4141
pre-commit run --all-files &&
4242
[ -z "$(git status --porcelain)" ]

src/neptune_api_codegen/cli.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ def build_parser() -> argparse.ArgumentParser:
4848
help="Path to the neptune backend repository. If not specified, it will be auto-detected.",
4949
default=None,
5050
)
51+
parser.add_argument(
52+
"--no-update-api-spec",
53+
action="store_true",
54+
help="Do not fetch new API spec files from Neptune repo.",
55+
default=False,
56+
)
5157
parser.add_argument(
5258
"--update",
5359
action="store_true",
@@ -140,14 +146,17 @@ def main() -> None:
140146
# Project root
141147
project_root = find_project_root()
142148

143-
# Neptune repo path
144-
if args.neptune_repo_path is None:
145-
args.neptune_repo_path = find_neptune_repo(project_root)
146-
elif not is_neptune_repo(args.neptune_repo_path):
147-
raise RuntimeError(
148-
f"The specified neptune repo path {args.neptune_repo_path} is not a valid neptune backend repository."
149-
)
150-
print_err(f"Using neptune backend repository at: {rel(args.neptune_repo_path)}")
149+
update_api_spec = not args.no_update_api_spec
150+
151+
if update_api_spec:
152+
# Neptune repo path
153+
if args.neptune_repo_path is None:
154+
args.neptune_repo_path = find_neptune_repo(project_root)
155+
elif not is_neptune_repo(args.neptune_repo_path):
156+
raise RuntimeError(
157+
f"The specified neptune repo path {args.neptune_repo_path} is not a valid neptune backend repository."
158+
)
159+
print_err(f"Using neptune backend repository at: {rel(args.neptune_repo_path)}")
151160

152161
# Target and backup dirs
153162
rand_bit = int(random() * 1e4)
@@ -174,12 +183,16 @@ def main() -> None:
174183
apispec_dir.mkdir()
175184
generated_py_dir.mkdir()
176185

177-
print_err(f"Copying proto directories and swagger files to: {rel(apispec_dir)}")
178-
copy_swagger_files(
179-
neptune_repo_path=args.neptune_repo_path,
180-
target_dir=apispec_dir,
181-
verbose=args.verbose,
182-
)
186+
if update_api_spec:
187+
print_err(f"Copying proto directories and swagger files to: {rel(apispec_dir)}")
188+
copy_swagger_files(
189+
neptune_repo_path=args.neptune_repo_path,
190+
target_dir=apispec_dir,
191+
verbose=args.verbose,
192+
)
193+
else:
194+
print_err(f"Using proto directories and swagger from: {rel(target_apispec)}")
195+
shutil.copytree(target_apispec, apispec_dir, dirs_exist_ok=True)
183196

184197
print_err(f"Generating OpenAPI clients in: {rel(generated_py_dir)}")
185198
run_in_docker(

0 commit comments

Comments
 (0)