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
* Add new python client
* Add first round of pagincation cod
* Add first unit test
* Add unit test
* fix a bug
* update tests
* Simplify code
* update tests
* add test case
* remove unused file
* add a new record
* Add a test
* add another test
* combine test
* Add another test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add a test
* Add keyword restriction
* rename pagesize to top
* Add unit tests
* update tests
* update tests
* limit package version
* limit package version
* update
* update tests
* update datetime
* update recording and readme
* update unit tests
* update length count
* update unit test
* update unit test
* remove aio folder
---------
Co-authored-by: Yi Gu <guyi@microsoft.com>
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+79-7Lines changed: 79 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,18 +67,90 @@ To read more about how to create and update recordings for testing code that int
67
67
68
68
Before merging your code contribution to `main`, make sure that all new code is covered by unit tests and that the unit tests have up-to-date recordings. If you recorded your tests and then updated or refactored the code afterwards, remember to re-record the tests.
69
69
70
-
### Update/re-generate the Azure Quantum internal SDK client based on Swagger###
70
+
### Update/re-generate the Azure Quantum internal SDK client ###
71
71
72
72
The internal Azure Quantum Python SDK client (`azure/quantum/_client`) needs to be re-generated every time there is a change in the [Azure Quantum Service API definition](https://github.com/Azure/azure-rest-api-specs/tree/main/specification/quantum/data-plane) (aka Swagger).
73
73
74
-
To re-generate the client based on the latest published API definition simply run the following PowerShell script
74
+
#### Prerequisites
75
+
Python 3.8 or later is required
75
76
76
-
```powershell
77
-
./eng/Generate-DataPlane-Client.ps1
78
-
```
79
-
> See the Generate-DataPlane-Client.ps1 script for more options
77
+
linux
78
+
79
+
sudo apt install python3
80
+
81
+
sudo apt install python3-pip
82
+
83
+
sudo apt install python3.{?}-venv explicitly if needed
84
+
85
+
Node.js 18.3 LTS or later is required
86
+
87
+
#### Setup your repo
88
+
Fork and clone the azure-sdk-for-python repo (we call it's name SDK repo and it's absolute path)
89
+
90
+
Create a branch in SDK repo to work in
91
+
92
+
Make sure your typespec definition is merged into main branch of public rest repo (we call it rest repo) or you already make a PR in rest repo so that you could get the github link of your typespec definition which contains commit id (e.g. https://github.com/Azure/azure-rest-api-specs/blob/46ca83821edd120552403d4d11cf1dd22360c0b5/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml)
93
+
94
+
#### Project service name and package name
95
+
Two key pieces of information for your project are the service_name and package_name.
96
+
97
+
The service_name is the short name for the Azure service. The service_name should match across all the SDK language repos and should be name of the directory in the specification folder of the azure-rest-api-specs repo that contains the REST API definition file. An example is Service Bus, whose API definitions are in the specification/servicebus folder of the azure-rest-api-specs repo, and uses the service_name "servicebus". Not every service follows this convention, but it should be the standard unless there are strong reasons to deviate.
98
+
99
+
In Python, a project's package name is the name used to publish the package in PyPI. For data plane libraries (management plane uses a different convention), the package_name could be just azure-{service_name}. An example is "azure-servicebus".
100
+
101
+
Some services may need several different packages. For these cases a third component, the module_name, is added to the package_name, as azure-{service_name}-{module_name}. The module_name usually comes from the name of the REST API file itself or one of the directories toward the end of the file path. An example is the Synapse service, with packages azure-synapse, azure-synapse-accesscontrol, azure-synapse-artifacts, etc.
102
+
103
+
#### Project folder structure
104
+
Before we start, we probably should get to know the project folder for SDK repo.
105
+
106
+
Normally, the folder structure would be something like:
107
+
108
+
sdk/{service_name}/{package_name}: the PROJECT_ROOT folder
109
+
/azure/{service_name}/{module_name} : folder where generated code is.
110
+
/tests: folder of test files
111
+
/samples: folder of sample files
112
+
azure-{service_name}-{module_name}: package name. Usually, package name is same with part of ${PROJECT_ROOT} folder. After release, you can find it in pypi. For example: you can find azure-messaging-webpubsubservice in pypi.
113
+
there are also some other files (like setup.py, README.md, etc.) which are necessary for a complete package.
114
+
More details on the structure of Azure SDK repos is available in the Azure SDK common repo.
115
+
116
+
#### How to generate SDK code with Dataplane Codegen
117
+
We are working on to automatically generate everything right now, but currently we still need some manual work to get a releasable package. Here're the steps of how to get the package.
118
+
119
+
1. Configure python emitter in tspconfig.yaml
120
+
In rest repo, there shall be tspconfig.yaml where main.tsp of your service is. Make sure there are configuration for Python SDK like:
121
+
122
+
parameters:
123
+
"service-dir":
124
+
default: "YOUR_SERVICE_DIRECTORY"
125
+
126
+
emit: [
127
+
"@azure-tools/typespec-autorest", // this value does not affect python code generation
128
+
]
129
+
130
+
options:
131
+
"@azure-tools/typespec-python":
132
+
package-dir: "YOUR_PACKAGE_NAME"
133
+
package-name: "{package-dir}"
134
+
flavor: "azure"
135
+
YOUR_PACKAGE_NAME is your package name; YOUR_SERVICE_DIRECTORY is SDK directory name. For example, assume that package name is "azure-ai-anomalydetector" and you want to put it in folder "azure-sdk-for-python/sdk/anomalydetector", then "YOUR_PACKAGE_NAME" is "azure-ai-anomalydetector" and "YOUR_SERVICE_DIRECTORY" is "sdk/anomalydetector"
An example of YOUR_REMOTE_TSPCONFIG_URL is https://github.com/Azure/azure-rest-api-specs/blob/46ca83821edd120552403d4d11cf1dd22360c0b5/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml
145
+
146
+
To update your TypeSpec generated SDK, go to your SDK folder where your tsp-location.yaml is located, call:
147
+
148
+
D:\dev\azure-sdk-for-python\sdk\contoso\azure-contoso-widget> tox run -e generate -c ..\..\..\eng\tox\tox.ini --root .
149
+
Note: To know more about tox, read our contributing guidelines
150
+
151
+
The tox run -e generate call will look for a tsp-location.yaml file in your local directory. tsp-location.yaml contains the configuration information that will be used to sync your TypeSpec project and generate your SDK. Please make sure that the commit is targeting the correct TypeSpec project updates you wish to generate your SDK from.
80
152
81
-
After re-generating the client make sure to:
153
+
#### After re-generating the client make sure to:
82
154
83
155
1. Re-run/Re-record all unit tests against the live-service (you can run `./eng/Record-Tests.ps1`)
84
156
1. If necessary, adjust the convenience layer for breaking-changes or to expose new features
0 commit comments