Closed mc3784 closed 2 months ago
thank you for opening this issue @mc3784 I'm going to take a look today
This is because there are two definitions of Link
in the spec: here and here. Python isn't able to deal with models of the same name in different namespaces. This is a feature-lack that we have this issue open for. We don't have a timeline for being able to generate models under different namesapces, is this something you guys really need? If not, I'd recommend for now a model rename.
Hello I was trying to generate the python sdk using this command:
tsp-client init -c https://github.com/Azure/azure-rest-api-specs-pr/blob/dcd30a31e125cfb4f1e256db611aea8ac99bcb52/specification/orbitalplanetarycomputer/Orbital.Spatio/tspconfig.yaml
I got a message back suggesting that this might be a bug and asking to file a bug here. Can somebody take a look and let me know if this is a bug or if I am doing something wrong? Thank you so much!
Following the full output:
`Use output directory 'C:/One/azure-sdk-for-python'? (y/n) y Using output directory 'C:/One/azure-sdk-for-python'
888 888 d8b 888 888 888 Y8P 888 888 888 888 888888 .d8888b 88888b. .d8888b 888 888 .d88b. 88888b. 888888 888 88K 888 "88b d88P" 888 888 d8P Y8b 888 "88b 888 888 "Y8888b. 888 888 888888 888 888 888 88888888 888 888 888 Y88b. X88 888 d88P Y88b. 888 888 Y8b. 888 888 Y88b. "Y888 88888P' 88888P" "Y8888P 888 888 "Y8888 888 888 "Y888 888 888 888
tsp-client version: 0.9.2 Found emitter package @azure-tools/typespec-python SDK initialized in C:/One/azure-sdk-for-python/sdk/geocatalog/geocatalog Found emitter package @azure-tools/typespec-python Installing dependencies from npm...
added 95 packages, and audited 96 packages in 47s
12 packages are looking for funding run
npm fund
for detailsfound 0 vulnerabilities Resolved path: C:/One/azure-sdk-for-python/sdk/geocatalog/geocatalog/TempTypeSpecFiles/Orbital.Spatio/node_modules/@typespec/compiler Compiling tsp using @azure-tools/typespec-python... Traceback (most recent call last): File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python\generator\pygen\codegen__init.py", line 334, in
).process()
^^^^^^^^^
File "C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python\generator\pygen\codegen__init__.py", line 318, in process
code_model = CodeModel(yaml_data=yaml_data, options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python\generator\pygen\codegen\models\code_model.py", line 67, in init__
self.sort_model_types()
File "C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python\generator\pygen\codegen\models\code_model.py", line 220, in sort_model_types
sorted_object_schemas.extend(self._sort_model_types_helper(schema, seen_schema_names, seen_schema_yaml_ids))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python\generator\pygen\codegen\models\code_model.py", line 197, in _sort_model_types_helper
raise ValueError(f"We have already generated a schema with name {current.name}")
ValueError: We have already generated a schema with name Link
Error: Command failed: py -3 C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python/scripts/run_tsp.py --output-folder=C:/One/azure-sdk-for-python/sdk/geocatalog/geocatalog --cadl-file=C:/Users/miceru/AppData/Local/Temp/cadl-codegen/typespec-python-yaml-mapec0ac960-70ea-4a79-a1bf-e8972b5587ee.yaml --package-version=1 --generate-packaging-files=true --flavor=azure --basic-setup-py=true --package-dir=geocatalog --package-name=geocatalog --models-mode=dpg --package-mode=azure-dataplane --emit-cross-language-definition-file=true --from-typespec=true
ExternalError: Emitter "@azure-tools/typespec-python" crashed! This is a bug.
Please file an issue at https://github.com/Azure/autorest.python/issues
Error: Command failed: C:\Program Files\nodejs\node.exe C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python/scripts/run-python3.cjs C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python/scripts/run_tsp.py --output-folder=C:/One/azure-sdk-for-python/sdk/geocatalog/geocatalog --cadl-file=C:/Users/miceru/AppData/Local/Temp/cadl-codegen/typespec-python-yaml-mapec0ac960-70ea-4a79-a1bf-e8972b5587ee.yaml --package-version=1 --generate-packaging-files=true --flavor=azure --basic-setup-py=true --package-dir=geocatalog --package-name=geocatalog --models-mode=dpg --package-mode=azure-dataplane --emit-cross-language-definition-file=true --from-typespec=true Traceback (most recent call last): File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python\generator\pygen\codegen__init.py", line 334, in
).process()
^^^^^^^^^
File "C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python\generator\pygen\codegen__init__.py", line 318, in process
code_model = CodeModel(yaml_data=yaml_data, options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python\generator\pygen\codegen\models\code_model.py", line 67, in init__
self.sort_model_types()
File "C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python\generator\pygen\codegen\models\code_model.py", line 220, in sort_model_types
sorted_object_schemas.extend(self._sort_model_types_helper(schema, seen_schema_names, seen_schema_yaml_ids))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python\generator\pygen\codegen\models\code_model.py", line 197, in _sort_model_types_helper
raise ValueError(f"We have already generated a schema with name {current.name}")
ValueError: We have already generated a schema with name Link
Error: Command failed: py -3 C:\One\azure-sdk-for-python\sdk\geocatalog\geocatalog\TempTypeSpecFiles\Orbital.Spatio\node_modules\@azure-tools\typespec-python/scripts/run_tsp.py --output-folder=C:/One/azure-sdk-for-python/sdk/geocatalog/geocatalog --cadl-file=C:/Users/miceru/AppData/Local/Temp/cadl-codegen/typespec-python-yaml-mapec0ac960-70ea-4a79-a1bf-e8972b5587ee.yaml --package-version=1 --generate-packaging-files=true --flavor=azure --basic-setup-py=true --package-dir=geocatalog --package-name=geocatalog --models-mode=dpg --package-mode=azure-dataplane --emit-cross-language-definition-file=true --from-typespec=true
Library Version 0.25.0 TypeSpec Compiler Version 0.57.0 --------------------------------------------------`