Skip to content

Apply code upgrades for python >= 3.7 - #9401

Merged
ramiro050 merged 1 commit into
iree-org:mainfrom
ramiro050:python-upgrade
Jun 13, 2022
Merged

ramiro050 merged 1 commit into
iree-org:mainfrom
ramiro050:python-upgrade

Conversation

@ramiro050

@ramiro050 ramiro050 commented Jun 8, 2022 •

Copy link
Copy Markdown
Member

This commit upgrades the python scripts to use the following features
supported since python 3.7:

  • postponed type annotations
  • dataclass
  • capture_output= and text= in some subprocess functions

This closes #4131

@GMNGeoffrey

Copy link
Copy Markdown
Member

We've already dropped support for Python 3.6 :-)

@ramiro050

Copy link
Copy Markdown
Member Author

We've already dropped support for Python 3.6 :-)

Oh! Should I go ahead and implement all the TODOs then?

@GMNGeoffrey

Copy link
Copy Markdown
Member

I would very much welcome that :-)

@ramiro050 ramiro050 changed the title Add TODOs for python>=3.7 upgrades Apply code upgrades for python >= 3.7 Jun 9, 2022
@ramiro050

Copy link
Copy Markdown
Member Author

I don't really understand what is going wrong with the pytype check. The error message does not seem related to my code changes

@ScottTodd

Copy link
Copy Markdown
Member

I don't really understand what is going wrong with the pytype check. The error message does not seem related to my code changes

That

ninja: error: build.ninja:40: multiple rules generate /home/runner/work/iree/iree/.pytype/pyi/iree_pydm/__init__.pyi [-w dupbuild=err]

"error" is safe to ignore. Sorry :/ Maybe we can turn off -w dupbuild=err somehow 🤔 (it's been an issue for a while, and prompted us to make that particular pytype check non-blocking)

@GMNGeoffrey GMNGeoffrey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, thank you. Please fix the PR description before merging and merge with a squash commit with title and description matching that of the PR, per https://github.com/google/iree/blob/main/CONTRIBUTING.md

Comment thread build_tools/scripts/utils.py Resolved
process = subprocess.run(command_line, capture_output=True, **run_args)
if process.returncode != 0:
raise CompilerToolError(process)
# Emit stderr contents.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess Stella is doing something more complicated than just printing directly to stderr here, though I'm still a little skeptical that this couldn't use the default behavior.

@GMNGeoffrey

Copy link
Copy Markdown
Member

Maybe we can turn off -w dupbuild=err somehow thinking (it's been an issue for a while, and prompted us to make that particular pytype check non-blocking)

Hmmm it seems like that should actually be really easy to do: https://github.com/google/iree/blob/427a94a09be70631c5d9f89d12616bb7f1954257/build_tools/pytype/check_diff.sh#L56

@ramiro050 can you try editing that line in this PR so we can test if it makes the error go away (we can actually make the change in a separate PR, since it's not really releated)

@MaheshRavishankar
MaheshRavishankar removed their request for review June 9, 2022 22:58
@ramiro050
ramiro050 force-pushed the python-upgrade branch 3 times, most recently from bdea0ce to 29286dc Compare June 9, 2022 23:20
@ramiro050

Copy link
Copy Markdown
Member Author

@ramiro050 can you try editing that line in this PR so we can test if it makes the error go away (we can actually make the change in a separate PR, since it's not really releated)

I tried adding dupbuild and dupbuild-error to the list of errors to disable, but that did not fix it

@GMNGeoffrey

GMNGeoffrey commented Jun 9, 2022 •

Copy link
Copy Markdown
Member

It seems we are not alone in this problem: google/pytype#198. And it's a ninja flag, not a pytype flag.

@GMNGeoffrey

Copy link
Copy Markdown
Member

To be clear, this is not a problem you need to solve for this PR and you can merge past the pytype errors. Although looking at the build failures you're getting, this could be something that would've been caught by pytype.

@ramiro050
ramiro050 force-pushed the python-upgrade branch 6 times, most recently from 3e3efb2 to cdaf90c Compare June 13, 2022 20:58
@ramiro050
ramiro050 force-pushed the python-upgrade branch 2 times, most recently from 1b4ae38 to 7578c15 Compare June 13, 2022 21:33
This commit upgrades the python scripts to use the following features
supported since python 3.7:

- postponed type annotations
- `dataclass`
- `capture_output=` and `text=` in some `subprocess` functions

This closes iree-org#4131
@ramiro050
ramiro050 merged commit a34c7ac into iree-org:main Jun 13, 2022
@ramiro050
ramiro050 deleted the python-upgrade branch June 13, 2022 23:21
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.

Code upgrades for python >= 3.7

3 participants