Fix bug to make --clear-output-folder work (solution 1)#1410
Fix bug to make --clear-output-folder work (solution 1)#1410msyyc wants to merge 11 commits intoautorestv3from
--clear-output-folder work (solution 1)#1410Conversation
|
|
||
| output-artifact: python-files | ||
| ``` | ||
|
|
There was a problem hiding this comment.
I don't find effective way to flush the buffer into disk in time. How about changing another way: if we format the file content before write, we can avoid the annoying problem. What's more, we reduce black plugin to make the flow shorter which is cleaner.
There was a problem hiding this comment.
and it would be breaking to make users not be able to turn off black
@iscai-msft users can still turn off black: https://github.com/Azure/autorest.python/pull/1410/files#r961250499 and https://github.com/Azure/autorest.python/pull/1410/files#r961250788 which will not bring breaking change. And multiapi/multiclient can also use black after this PR.
00e5a37 to
1c14ce1
Compare
ca3fd9d to
16eb4d2
Compare
| "Loading python.json file. This behavior will be depreacted" | ||
| ) | ||
| self.options.update(python_json) | ||
| self._black = python_json.get("black", True) |
There was a problem hiding this comment.
users can still turn off black (cadl-python)
There was a problem hiding this comment.
@msyyc is there really no way to keep black as a separate plugin? Conceptually it really is a plugin, so it makes the code a lot less clean by adding black throughout the different plugins. I can take a look in a bit to see if it can't be done, but I think there should be a way to fix the current plugin we have, instead of doing this refactoring
There was a problem hiding this comment.
@iscai-msft It is nice if you can take a look. stream.flush can't ensure flush to disk before black read it. The memory inconsistency is always hard to handle so I think the best way is to bypass it completely. Plugin black may be clean but it can't work for multiapi/multiclient. In one word, my fix pr is just one of possible ways but I think it can resolve the problem for good.
nit: the bug seriously influence our release for mgmt SDK so I hope it can be resolved asap.
add @lmazuel for awareness.
| ) -> None: | ||
| super().__init__(output_folder=output_folder) | ||
| self._autorestapi = autorestapi | ||
| self._black = autorestapi.get_boolean_value("black", True) |
There was a problem hiding this comment.
users can still turn off black(autorest)
|
What's the reason that many samples/tests files get updated? Is it because previously black did not apply to them due to the bug? |
Yeah. And with the fix, |
--clear-output-folder work--clear-output-folder work (solution 1)
|
close for #1434 |
--clear-output-folderdoes not work forautorest.python > 5.19.0#1409write_filecan't make sure to flush the buffer to disk beforeblackread and format all files from disk:autorest.python/packages/autorest.python/autorest/jsonrpc/stdstream.py
Lines 46 to 52 in ba0cb0e
autorest.python/packages/autorest.python/autorest/black/__init__.py
Lines 31 to 39 in ba0cb0e