Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: @azure-tools/typespec-python tsp compile --watch broken #2248

Open
4 tasks done
johanste opened this issue Feb 22, 2025 · 0 comments
Open
4 tasks done

[Bug]: @azure-tools/typespec-python tsp compile --watch broken #2248

johanste opened this issue Feb 22, 2025 · 0 comments
Labels
bug Something isn't working needs-area

Comments

@johanste
Copy link
Member

Describe the bug

Looks like data is being retained across emit calls....

Reproduction

@service
namespace Repro;

model Something {
    data: string;
}

op doSomething(...Something): Something;
$> tsp compile . --watch --emit=@azure-tools/typespec-python

Compiles first time. Add some newlines. Save the file. Kaboom.

raceback (most recent call last):
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/eng/scripts/setup/run_tsp.py", line 41, in <module>
    codegen.CodeGenerator(output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args).process()
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/__init__.py", line 343, in process
    code_model = CodeModel(yaml_data=yaml_data, options=options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/models/code_model.py", line 89, in __init__
    self.sort_model_types()
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/models/code_model.py", line 385, in sort_model_types
    sorted_object_schemas.extend(self._sort_model_types_helper(schema, seen_schema_names, seen_schema_yaml_ids))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/models/code_model.py", line 362, 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 Something
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: /Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/venv/bin/python /Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/eng/scripts/setup/run_tsp.py --package-version=1.0.0b1 --generate-packaging-files=true --flavor=azure --package-dir=azureaifoundry --package-name=azureaifoundry --models-mode=dpg --package-mode=azure-dataplane --enable-typespec-namespace=false --emit-cross-language-definition-file=true --from-typespec=true --output-folder=/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/tsp-output/@azure-tools/typ
Traceback (most recent call last):
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/eng/scripts/setup/run_tsp.py", line 41, in <module>
    codegen.CodeGenerator(output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args).process()
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/__init__.py", line 343, in process
    code_model = CodeModel(yaml_data=yaml_data, options=options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/models/code_model.py", line 89, in __init__
    self.sort_model_types()
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/models/code_model.py", line 385, in sort_model_types
    sorted_object_schemas.extend(self._sort_model_types_helper(schema, seen_schema_names, seen_schema_yaml_ids))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/models/code_model.py", line 362, 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 Something
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: /Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/venv/bin/python /Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/eng/scripts/setup/run_tsp.py --package-version=1.0.0b1 --generate-packaging-files=true --flavor=azure --package-dir=azureaifoundry --package-name=azureaifoundry --models-mode=dpg --package-mode=azure-dataplane --enable-typespec-namespace=false --emit-cross-language-definition-file=true --from-typespec=true --output-folder=/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/tsp-output/@azure-tools/typespec-python --cadl-file=/var/folders/xx/z3qhdzcs091cvczt40lly1c00000gn/T/cadl-codegen/python-yaml-path773df198-c0bd-4da9-a6ab-508f8b28f29f.yaml
Traceback (most recent call last):
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/eng/scripts/setup/run_tsp.py", line 41, in <module>
    codegen.CodeGenerator(output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args).process()
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/__init__.py", line 343, in process
    code_model = CodeModel(yaml_data=yaml_data, options=options)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/models/code_model.py", line 89, in __init__
    self.sort_model_types()
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/models/code_model.py", line 385, in sort_model_types
    sorted_object_schemas.extend(self._sort_model_types_helper(schema, seen_schema_names, seen_schema_yaml_ids))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/generator/pygen/codegen/models/code_model.py", line 362, 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 Something

    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at checkExecSyncError (node:child_process:891:11)
    at execSync (node:child_process:963:15)
    at $onEmit (file:///Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/http-client-python/dist/emitter/emitter.js:163:13)
    at async Object.$onEmit [as emitFunction] (file:///Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@azure-tools/typespec-python/dist/src/emitter.js:7:5)
    at async runEmitter (file:///Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/compiler/dist/src/core/program.js:368:13)
    at async compile (file:///Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/compiler/dist/src/core/program.js:124:9)
    at async run (file:///Users/johanstenberg/ongoing/uxagent/agent-first-sdk/typespec/node_modules/@typespec/compiler/dist/src/core/cli/actions/compile/compile.js:63:24)

--------------------------------------------------
Library Version                0.38.4
TypeSpec Compiler Version      0.65.3
--------------------------------------------------

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the TypeSpec repo
  • Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@johanste johanste added the bug Something isn't working label Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-area
Projects
None yet
Development

No branches or pull requests

1 participant