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

Feature/faster build #5417

Merged
merged 5 commits into from
Nov 2, 2023
Merged

Conversation

khancyr
Copy link
Contributor

@khancyr khancyr commented Sep 12, 2023

correct some python code on update.py
convert wget call to pure python equivalent that are faster. Make the download files from https://autotest.ardupilot.org in parallele to speed up the build

@Hwurzburg
Copy link
Contributor

Hwurzburg commented Sep 12, 2023

Seems a bit faster on my local builds....even without the --fast option

update.py Show resolved Hide resolved
@khancyr khancyr force-pushed the feature/faster-build branch 2 times, most recently from 1bf5630 to 4bb5cee Compare September 13, 2023 12:51
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I might quite like the meat of these changes.

But they are mixed in with a whole heap of changes to update the Python code. Most of which are good - unicode string stuff, utf-declarations, fstrings etc. This just makes it far more difficult to review than it should be.

This is only a partial review as I got frustrated with working through changes unrelated to the changes in the parameter and log information download.

@@ -14,18 +14,18 @@

for f in args.files:
print("Processing %s" % f)
txt = open(f, 'r').read()
txt = open(f).read()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PathLib is the more-modern way still...

matches = re.findall(r'[,.\s][A-Z][A-Z0-9]+_[A-Z_]+[,.\s]', txt)
matches = re.findall(r'[,.\s][A-Z]+_[A-Z_]+[,.\s]', txt)
changed = False
for m in matches:
s = str(m)
param = s.strip()
s2 = "%s:ref:`%s<%s>`%s" % (s[0], param, param, s[-1])
s2 = f"{s[0]}:ref:`{param}<{param}>`{s[-1]}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change tested?

subprocess.check_call(["powershell.exe", "Start-BitsTransfer", "-Source", fetchurl])
else:
subprocess.check_call(["wget", fetchurl])
def fetch_and_rename(fetchurl: str, target_file: str, new_name: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This yieldssyntax isn't in all of Python3, is it? When did it come in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comes with python3.5 and it is really usefull to track bugs !

update.py Outdated Show resolved Hide resolved
update.py Outdated Show resolved Hide resolved
f'{dataname.lower()}.rst', site, cache)


def fetchlogmessages(site: Optional[str] = None, cache: Optional[str] = None) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These types make things rather less readable.

@khancyr
Copy link
Contributor Author

khancyr commented Sep 13, 2023

@peterbarker I didn't intend to make a huge python3 style update, but Charlie said : hey why not use f-string. So I ran pyupgrade to modernize all .py in one go.

Beside the file downloading, I didn't intend to modify the logic nor refactor everything.

@peterbarker
Copy link
Contributor

@peterbarker I didn't intend to make a huge python3 style update, but Charlie said : hey why not use f-string. So I ran pyupgrade to modernize all .py in one go.

Beside the file downloading, I didn't intend to modify the logic nor refactor everything.

You could probably do that style update and rebase on top of that, then.

I'm still a touch worried about (a) the "yields" syntax which I thought was relatively new, and the readability with the Types system. OTOH, I was tired and a bit grumpy on first review, so we'll see what happens on a second review :-)

Love f-strings :-)

@TunaLobster
Copy link
Contributor

Sphinx 5.1.1 is the current minimum for the ArduPilot wiki. That requires python 3.6 or newer. Generators showed up before then so everything is good there.

Type hints are also great for quickly coming up to speed with what is happening. They don't do much until coupled with a linter or static analyzer.

@peterbarker
Copy link
Contributor

Sphinx 5.1.1 is the current minimum for the ArduPilot wiki. That requires python 3.6 or newer. Generators showed up before then so everything is good there.

Ah, sorry, I was referring to what's apparently known as "return type annotations". I was using the older meaning of "yields" as synonymous with "returns", as opposed to the Pythonesque "yields" for generators.

Type hints are also great for quickly coming up to speed with what is happening. They don't do much until coupled with a linter or static analyzer.

Are they, 'though? It's harder to just glance at a function definition and see what it's taking. I do think we should find out - but introducing their syntax really should be done in a separate PR. If we can show that flake8 can now pick up more bugs, bringing it in would be a no-brainer IMO. I don't think one could argue that it does make the syntax more scary, 'though.

Please note that you don't need my approval to merge this PR. If you want to merge it with Henry's blessing that's workable. It's just that if it breaks its likely to stay broken until you fix it :-)

We're not running out of PR numbers. I would have merged the unicode and f-string changes instantly.

@khancyr
Copy link
Contributor Author

khancyr commented Sep 14, 2023

@peterbarker flake8 doesn't do type checking. The best tool for now is mypy or IDE if it support typing.
One issue thus is that without setting at least the return type, most analyzers will just consider that the function take anything as input and return anything so they only report big error. Using typing, you have a better check on the return condition and avoid some strange casting.
I am not totally fine with typing as is could be really annoying to type and read, but it provides good bug tracking ... so I try to add it by default now

@Hwurzburg
Copy link
Contributor

@peterbarker Peter, still needs changes? or can I merge?

@Hwurzburg
Copy link
Contributor

@khancyr @peterbarker says his review stands....I wont merge unless you two come to an understanding...sorry

@khancyr
Copy link
Contributor Author

khancyr commented Oct 10, 2023

no problem, I will improve this

@khancyr khancyr force-pushed the feature/faster-build branch 2 times, most recently from 0bccf34 to 9165821 Compare October 31, 2023 08:38
@khancyr
Copy link
Contributor Author

khancyr commented Oct 31, 2023

@peterbarker removed py3 upgrade change, just the speedup now, will make an other PR for py3

@khancyr khancyr force-pushed the feature/faster-build branch from 9165821 to 79bc00f Compare November 2, 2023 13:34
@khancyr khancyr merged commit 9dcdbdf into ArduPilot:master Nov 2, 2023
4 checks passed
@khancyr khancyr deleted the feature/faster-build branch November 2, 2023 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants