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

[MRG] Add CI builds for Python 3.11 #1659

Merged
merged 5 commits into from Oct 4, 2022
Merged

Conversation

mrbean-bremen
Copy link
Member

@mrbean-bremen mrbean-bremen commented Jul 8, 2022

Describe the changes

For some reason, Python 3.11 did not like the second condition in the regex (the check for group 7 matching).
I replaced the matches with more optional groups.

Tasks

  • Unit tests added that reproduce the issue or prove feature is working - n.a.
  • Fix or feature added
  • Code typed and mypy shows no errors
  • Documentation updated (if relevant)
    • No warnings during build
    • Preview link (CircleCI -> Artifacts -> doc/_build/html/index.html)
  • Unit tests passing and overall coverage the same or better

@codecov
Copy link

codecov bot commented Jul 8, 2022

Codecov Report

Merging #1659 (c32358c) into master (f8cf45b) will increase coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #1659      +/-   ##
==========================================
+ Coverage   97.58%   97.60%   +0.01%     
==========================================
  Files          66       66              
  Lines       10737    10737              
==========================================
+ Hits        10478    10480       +2     
+ Misses        259      257       -2     
Impacted Files Coverage Δ
pydicom/valuerep.py 99.41% <ø> (ø)
pydicom/filebase.py 99.19% <0.00%> (+1.61%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@mrbean-bremen mrbean-bremen changed the title [WIP] Add CI builds for Python 3.11 [MRG] Add CI builds for Python 3.11 Jul 8, 2022
| 2.3 | March 2022 | 3.6, 3.7, 3.8, 3.9, 3.10 |
+-----------------+------------------+---------------------------+
| 2.4 | ~September 2022 | 3.7, 3.8, 3.9, 3.10, 3.11 |
+-----------------+------------------+---------------------------+
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed 3.6 here as it is EOL since last year, but I'm not sure if this is correct - did we have some plan here?

Copy link
Member

Choose a reason for hiding this comment

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

I don't recall if we had a plan, but it makes sense to drop it.

- change regex to be compatible with Python 3.11
- fixes pydicom#1658
@@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11-dev']
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we also remove 3.6 here (and for typing)?

Copy link
Member Author

Choose a reason for hiding this comment

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

True, will do this tonight. I had just waited for feedback...

@mrbean-bremen mrbean-bremen changed the title [MRG] Add CI builds for Python 3.11 [WIP] Add CI builds for Python 3.11 Sep 22, 2022
@mrbean-bremen
Copy link
Member Author

mrbean-bremen commented Sep 22, 2022

It uses an old Pypi version, will check this tonight...
BTW, removing 3.6 support also allows us to use dataclasses (as done in the example code for walk in #1696).

@mrbean-bremen mrbean-bremen changed the title [WIP] Add CI builds for Python 3.11 [MRG] Add CI builds for Python 3.11 Sep 22, 2022
@mrbean-bremen
Copy link
Member Author

I think this is ready to merge.

@darcymason darcymason merged commit 183a3ef into pydicom:master Oct 4, 2022
@darcymason
Copy link
Member

I see that a couple of 3.11 parts did not pass on the master merge action.

@mrbean-bremen
Copy link
Member Author

Right, I missed this! These are the tests that are not run for the PR, correct?
Looks like CharPyLS is not compiling under 3.11... maybe we shall disable the jpeg-ls tests for Python 3.11 until this is fixed, what do you think?

@darcymason
Copy link
Member

maybe we shall disable the jpeg-ls tests for Python 3.11 until this is fixed, what do you think?

Yes, that seems very reasonable.

Interesting that CharPyLS does not install in Windows either when you look into the full log, but that section of the github actions does not show as an error; it just skips it without complaint.

@mrbean-bremen
Copy link
Member Author

Interesting that CharPyLS does not install in Windows either when you look into the full log, but that section of the github actions does not show as an error; it just skips it without complaint.

I actually didn't notice this, I just saw that the test seemed to succeed - in this case I will disable it for all systems.

@mrbean-bremen
Copy link
Member Author

mrbean-bremen commented Oct 5, 2022

pylibjpeg-openjpeg pylibjpeg-libjpeg also don't build with Python 3.11... at least it works with Pillow and gdcm.

Comment on lines +778 to +779
r"((?P<s>([0-5][0-9]|60))"
r"(\.(?P<ms>([0-9]{1,6})?))?)?)?$"
Copy link

@Waszker Waszker Oct 25, 2022

Choose a reason for hiding this comment

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

@mrbean-bremen I'm sorry to bring this up but could you please elaborate why this pattern works?

Looking at it I think that it's not the same as it used to be, e.g. I think that in some cases it allows for <ms> group to be matched even if the <s> one did not match. Previously this <ms> group matching was dependent on the success of matching <s> group (via the ?(7)... syntax), whereas now it's not.

Also, I wonder whether this isn't a bug in Python re module? The previous regex is correctly recognized by some other regexp implementation, e.g. https://regex101.com/

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that in some cases it allows for group to be matched even if the <s> one did not match

I don't see this - as far as I understand, the group is an optional part of the expression above, while the <s> group is mandatory (in that scope, it is optional in the scope of the <m> group). Not sure if that was clear :) Anyway, if you can show me an example that would now incorrectly match, I stand corrected, of course.

Also, I wonder whether this isn't a bug in Python re module?

Yes, it is - but I think you filed it yourself? Anywhere, it will eventually be fixed, but it is not fixed in Python 3.11.0, so we cannot remove the fix yet. In case the fix (in pydicom) is incorrect, we have to change it of course, otherwise we can just leave it as is.

Copy link

Choose a reason for hiding this comment

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

I think that in some cases it allows for group to be matched even if the <s> one did not match

I don't see this - as far as I understand, the group is an optional part of the expression above, while the <s> group is mandatory (in that scope, it is optional in the scope of the <m> group). Not sure if that was clear :) Anyway, if you can show me an example that would now incorrectly match, I stand corrected, of course.

Ah you're right! Somehow I didn't notice the removal of the ? on the <s> group...

Also, I wonder whether this isn't a bug in Python re module?

Yes, it is - but I think you filed it yourself? Anywhere, it will eventually be fixed, but it is not fixed in Python 3.11.0, so we cannot remove the fix yet. In case the fix (in pydicom) is incorrect, we have to change it of course, otherwise we can just leave it as is.

Yes, I have filled in a bug report once I've confirmed that there is a problem with Python's re module, but that was after posting the question here. Sorry for making it look so confusing 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I have filled in a bug report once I've confirmed that there is a problem with Python's re module

Thanks for that, by the way, should have done this myself!

Sorry for making it look so confusing

It got me to re-check the fix, which is always a good thing. Anyway, I understand that leaving the fix in is ok, regardless of the Python re fix, so all is well.

pauldmccarthy added a commit to pauldmccarthy/xnat-feedstock that referenced this pull request Nov 2, 2022
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.

Pydicom not running under Python 3.11
3 participants