You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm in the process of migrating a brownfield service (Key Vault) to TypeSpec (Azure/azure-rest-api-specs#28708) and have been struggling to emit Python code that matches our original SDK structure. In azure-keyvault-certificates we keep all generated code in a _generated module; we'd like to emit from TSP into the same directory.
I'm able to match our original SDK structure by placing tsp-location.yaml in _generated/, emitting with tsp-client update, and manually deleting everything that's emitted apart from source code. However, this isn't an ideal solution:
This manual work is tedious and can't be easily done with automation.
The modified SDK structure doesn't match the emitter's assumptions. For example, generated model references point to azure.keyvault.certificates.models, when the new location is azure.keyvault.certificates._generated.models. This would break references, e.g. in docs.
Packaging info we want to keep, like setup.py, isn't automatically updated. We'd like to emit from the root of the package so that packaging information gets correctly updated.
Attempted solutions
I've tried a number of configurations in tspconfig.yaml to achieve this, which haven't worked:
In all of these attempts, running tsp-client update from the root of azure-keyvault-certificates emits the code into the package root, instead of into _generated/. Here are the files that are changed (moving tsp-location.yaml to the package root was done manually; everything else is emitted):
Additional information
In these attempts I've been using the --local-spec-repo option, which may or may not be relevant. The tsp-client output consistently indicates that the output directory is the package root:
mcpatino@DESKTOP-DPKUD1A:~/azure-sdk-for-python/sdk/keyvault/azure-keyvault-certificates$ tsp-client update --local-spec-repo ../../../../azure-rest-api-specs/specification/keyvault/Security.KeyVault.Certificates/
Using output directory '/home/mcpatino/azure-sdk-for-python/sdk/keyvault/azure-keyvault-certificates'
...
The text was updated successfully, but these errors were encountered:
tldr: add generation-subdir. Here are the notes from our discussion
North Star
sdk/keyvault/azure-kevault-certificates
azure
-> keyvault
-> certificates
-> _version.py
-> _generated
-> _client.py
-> setup.py # needs to make sure that it packages everything in azure/keyvault/certificates, including _generated
tsp-client uses service-dir and package-dir. package-dir is where the setup.py is, so in this case azure-keyvault-certificates.
These are usually the same / inferred, here we're trying to customize generation root, while still keeping the packaging root the same, and including everything within it.
Context
I'm in the process of migrating a brownfield service (Key Vault) to TypeSpec (Azure/azure-rest-api-specs#28708) and have been struggling to emit Python code that matches our original SDK structure. In
azure-keyvault-certificates
we keep all generated code in a_generated
module; we'd like to emit from TSP into the same directory.I'm able to match our original SDK structure by placing
tsp-location.yaml
in_generated/
, emitting withtsp-client update
, and manually deleting everything that's emitted apart from source code. However, this isn't an ideal solution:azure.keyvault.certificates.models
, when the new location isazure.keyvault.certificates._generated.models
. This would break references, e.g. in docs.setup.py
, isn't automatically updated. We'd like to emit from the root of the package so that packaging information gets correctly updated.Attempted solutions
I've tried a number of configurations in
tspconfig.yaml
to achieve this, which haven't worked:"output-path"
:"./azure/keyvault/certificates/_generated"
"azure-keyvault-certificates/azure/keyvault/certificates/_generated"
"azure.keyvault.certificates._generated"
"emitter-output-dir"
:"./azure/keyvault/certificates/_generated"
"azure-keyvault-certificates/azure/keyvault/certificates/_generated"
"azure.keyvault.certificates._generated"
"namespace"
:"azure.keyvault.certificates._generated"
In all of these attempts, running
tsp-client update
from the root ofazure-keyvault-certificates
emits the code into the package root, instead of into_generated/
. Here are the files that are changed (movingtsp-location.yaml
to the package root was done manually; everything else is emitted):Additional information
In these attempts I've been using the
--local-spec-repo
option, which may or may not be relevant. Thetsp-client
output consistently indicates that the output directory is the package root:The text was updated successfully, but these errors were encountered: