Skip to content

Commit d850231

Browse files
authored
[Sdk generation pipeline] accept remote url to generate sdk (#41927)
* generate sdk from remote url * fix
1 parent 8cc1925 commit d850231

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

tools/azure-sdk-tools/packaging_tools/generate_utils.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -415,19 +415,21 @@ def gen_typespec(
415415
typespec_python = "@azure-tools/typespec-python"
416416
# call scirpt to generate sdk
417417
try:
418-
tsp_dir = (Path(spec_folder) / typespec_relative_path).resolve()
419-
repo_url = rest_repo_url.replace("https://github.com/", "")
420-
tspconfig = tsp_dir / "tspconfig.yaml"
421-
if api_version and tspconfig.exists():
422-
with open(tspconfig, "r") as file_in:
423-
content = yaml.safe_load(file_in)
424-
if content.get("options", {}).get("@azure-tools/typespec-python"):
425-
content["options"]["@azure-tools/typespec-python"]["api-version"] = api_version
426-
with open(tspconfig, "w") as file_out:
427-
yaml.dump(content, file_out)
428-
cmd = (
429-
f"tsp-client init --tsp-config {tsp_dir} --local-spec-repo {tsp_dir} --commit {head_sha} --repo {repo_url}"
430-
)
418+
if spec_folder:
419+
tsp_dir = (Path(spec_folder) / typespec_relative_path).resolve()
420+
repo_url = rest_repo_url.replace("https://github.com/", "")
421+
tspconfig = tsp_dir / "tspconfig.yaml"
422+
if api_version and tspconfig.exists():
423+
with open(tspconfig, "r") as file_in:
424+
content = yaml.safe_load(file_in)
425+
if content.get("options", {}).get("@azure-tools/typespec-python"):
426+
content["options"]["@azure-tools/typespec-python"]["api-version"] = api_version
427+
with open(tspconfig, "w") as file_out:
428+
yaml.dump(content, file_out)
429+
cmd = f"tsp-client init --tsp-config {tsp_dir} --local-spec-repo {tsp_dir} --commit {head_sha} --repo {repo_url}"
430+
else:
431+
tsp_config_url = f"{rest_repo_url}/blob/{head_sha}/{typespec_relative_path}/tspconfig.yaml"
432+
cmd = f"tsp-client init -c {tsp_config_url}"
431433
if run_in_pipeline:
432434
emitter_name = "@azure-tools/typespec-python"
433435
if not os.path.exists(f"node_modules/{emitter_name}"):

tools/azure-sdk-tools/packaging_tools/sdk_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def main(generate_input, generate_output):
222222
with open(generate_input, "r") as reader:
223223
data = json.load(reader)
224224

225-
spec_folder = data["specFolder"]
225+
spec_folder = data.get("specFolder", "")
226226
sdk_folder = "."
227227
result = {}
228228
python_tag = data.get("python_tag")

0 commit comments

Comments
 (0)