azure / autorest.python Goto Github PK
View Code? Open in Web Editor NEWExtension for AutoRest (https://github.com/Azure/autorest) that generates Python code
License: MIT License
Extension for AutoRest (https://github.com/Azure/autorest) that generates Python code
License: MIT License
Support
This issue is about introducing mypy as part of the tox run, for both vanilla and azure. This means:
mypy should be run on both the generated code and the unittests (both Expected and AcceptanceTests folder)
Build should be clean with no errors. This might require update of annotations in msrest and msrestazure to solve some of them.
https://github.com/Azure/msrest-for-python/
https://github.com/Azure/msrestazure-for-python/
We have an API that has a description property containing the string:
"Value\Units"
When this description is converted to python, it generates the following string:
"""Value\Units"""
When evaluated, this gives the error:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 5-6: truncated \UXXXXXXXX escape
I couldn't tell for sure, but I didn't see anything in the OpenAPI definition that precluded the use of \ or \U in a description of an API.
https://swagger.io/specification/
It says:
Where common markdown syntax links to here.
Old autorest will generate "constant" if there was an enum with one unique value. We need to decide what to do once the modelerfour discussion cross language has been done:
https://github.com/Azure/autorest.modelerfour/issues/27
Support XML tests
Blocked by #136
Operations generation didn't really start yet
Having a pytest run of this test
With a swagger spec that identifies a model with a field named "self", the autorest generator for python results in this error on import:
SyntaxError: duplicate argument 'self' in function definition
These should ideally be renamed as something like _self
It seems when the a property is defined as enum (not x-ms-enum), then no validation code is generated for it. Neither the possible/allowed strings are available as an array or object in the generated code, nor does the validation logic in msrest/serialization.py have something for enum. Is this expected behavior?
Non-major. Ran into this today when attempting to track down customer request by id.
Update the code generator to have the full annotations on models_py3 and aio folder. Since this is Python 3 files, direct annotations can be used. Some of them are done already.
So roughly this means:
typing
import (List? Optional? Dict?, Any?) and import just that#82 needs to be done before to measure progress and status
Waiting on modelerfour to provide it to us:
https://github.com/Azure/autorest.modelerfour/issues/10
Example: method 1 takes XML, and method takes JSON.
https://docs.microsoft.com/en-us/rest/api/storageservices/create-permission
Some Python naming convention are not yet translater correctly to new autorest:
some param names aren't properly converted to python case (they're still capital) (RequiredOptional)
Message from @iscai-msft :
error generating HTTP, AzureHead, Paging, AzureSpecials etc (getting schema error when it looks in exception list) -> ask about how the excpetions list has been reformatted
Having pytest run of this test
Having a pytest run of this test
Having a pytest run of this test.
I understand that adding MISSING_DESCRIPTION is nice for development, created this issue to be sure we don't forget to address it before we assume we're done.
https://github.com/Azure/autorest.modelerfour/issues/30
The generated docstring for the msrestazure.azure_active_directory
parameter results in an invalid xref link in the reference docs for each library's management client.
Source: GeneratorSettingsPya.cs
Example from ContainerInstanceManagement:
Resultant generated code: container_instance_management_client.py
Message from @iscai-msft:
@johanste FYI
Work on https://github.com/Azure/autorest.python/tree/autorestv3
Short version:
Make the template structure to generate the models
folder ONLY (no operation yet at this point).
Dependency on #114 first to regenerate easily
Support LRO
For enum service we generated this:
not_applicable = "NotApplicable" #: User either hasn't started configuring their template
or they haven't started the configuration process.
instead of
not_applicable = "NotApplicable" #: User either hasn't started configuring their template or they haven't started the configuration process.
See https://github.com/Azure/azure-sdk-for-python/pull/4366/files
Support tests about Primitive:
Work on https://github.com/Azure/autorest.python/tree/autorestv3
Short version: port to Python these two calls:
gulp regenerate
gulp test
Suggestion is to use "invoke": http://www.pyinvoke.org/
Python version in pyinvoke of this gulp script:
https://github.com/Azure/autorest.python/blob/azure-core/.gulp/regeneration.iced
Assuming the testserver has been installed (npm install), this reads the Swaggers and call our current autorest with it to generate in the folders test/vanilla/Expected/AcceptanceTests
and test/azure/Expected/AcceptanceTests
Python version in pyinvoke of this part script:
autorest.python/.gulp/gulpfile.iced
Lines 23 to 27 in 1d943d2
IOW, run tox on both vanilla
and azure
folder
The current file structure of generated SDKs creates a "models" folder that contains:
This creates a LOT of files, example with Network:
https://github.com/Azure/azure-sdk-for-python/tree/master/azure-mgmt-network/azure/mgmt/network/v2018_10_01/models
We realized recently that all these tiny files have a massive impacts on performance:
Not only performance, but also documentation since it provides two ways to import the same file:
And actually on Python 3, these are not the same, since the first one includes the automatic choice between Python 3 or Python 2 file (where the second one is Python 2 specific). This creates issues and bugs in the CLI already.
We need to refactor this folder with less files, and fixing the doubling syntax at the same time. This is a breaking changes, and release should upgrade the major version of the resulting package.
I made a prototype of this in Python. This script should be called on generated Autorest folder (loaded in dev mode in a venv) that post-process and patch the files manually. The script is here:
https://gist.github.com/lmazuel/dad0ac92c733b27f6d81ea57a47625ce#file-patch_models_v2-py
The result is:
I released one package already with this patched folder, which can be used as reference:
https://github.com/Azure/azure-sdk-for-python/tree/master/azure-cognitiveservices-vision-contentmoderator/azure/cognitiveservices/vision/contentmoderator/models
CLI already releases using this script to post-process all SDKs (this means CLI doesn't ship the raw SDK but a patched version). We don't have any issues and then assume the prototype works as expected.
The target of this issue is to track backporting the logic of the Python script into Autorest by default.
The tricky part is the inheritance part. Because this new version will declare all classes, but they should be declared in inheritance order, so if B subclass A, A is defined before B in the Python file. The Python script here is doing it using the magic attribute mro
, and this logic has to be translated in Autorest core model (which is less intuitive).
Once this part is done, then it's mostly changing the output file of models and is not complicated.
Support BodyFile
Blocked by #134
The fish part of BodyComplex
class SpellCheckAPIConfiguration(Configuration):
"""Configuration for SpellCheckAPI
Note that all parameters used to create this instance are saved as instance
attributes.
:param credentials: Subscription credentials which uniquely identify
client subscription.
:type credentials: None
:param str base_url: Service URL
"""
def __init__(
self, credentials, base_url=None):
if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
if not base_url:
base_url = 'https://api.cognitive.microsoft.com/bing/v7.0'
Crash of modelerfour on BodyForm data https://github.com/Azure/autorest.modelerfour/issues/28
Autorest is supposed to have an option --keep-version-file that act as below:
Problem here:
This issue is about making sure it works as expected, and once it works push it to "azure" as well.
We don't the necessary information yet to conclude on this one, blocked by https://github.com/Azure/autorest.modelerfour/issues/12
Making unable to pass "enable_loggin" or things like this:
Support:
Crash of modelerfour https://github.com/Azure/autorest.modelerfour/issues/29
Not sure if bug or feature request but in my Swagger file I didn't specify any:
"ApiVersionParameter": { "name": "api-version", "in": "query", "required": true, "type": "string", "description": "Client Api Version." }
But in my generated code I still get:
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
In every operation, but I don't want it.
I'm using "@microsoft.azure/autorest.python": "^4.0.67", "autorest": "^3.0.5165",
Example:
class Foo(str, Enum):
error = "ERROR"
error = "Error"
Figure out what to do with model flattening, what part is modelerfour and what part is not:
https://github.com/Azure/autorest.modelerfour/issues/14
https://github.com/Azure/autorest.modelerfour/issues/13
> linux-x64 restart
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.