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

Drop python 2 idioms and compatibility fixes #1567

Merged
merged 12 commits into from
Feb 17, 2021

Conversation

ndevenish
Copy link
Member

@ndevenish ndevenish commented Jan 26, 2021

This PR drops most of the python 2/3 compatibility layers, drops requirements for six/futures, and updates lots of idioms to their newer equivalents.

The filters applied, separated into different commits (so we can drop them if there is something we are unsure about), are:

  • pyupgrade: Whole slew of python 2->3 upgrades, mostly including __future__, new-style classes, simple fstrings, modern super(), remove six. (47134df)
  • com2ann: Promote type-comments to type-annotations (2364d4b)
  • fix_logger_format.py: Custom refactor script to convert .format and % formatting inside logging calls to use the explicit logging lazy-format style. This means that they won't be auto-converted by flynt (38b6010).
  • Flynt: More extensive f-string rewriting. This is done using a custom branch with a few fixes to support more that we use; ' ' and '-' prefixes, converting int and len calls, and being slightly more cautious around complicated format-strings. (22b34b5)
  • Manual fixes for:
    • Removing all references to six and future (6405369)
    • Remove math.isclose backport (a44f1ea)
    • Clean up some redundant str() calls in converted f-strings, and some other minor format fixes. (65f3d41)

installer/bootstrap.py has been excluded from all conversions.

ndevenish and others added 10 commits January 26, 2021 11:28
  pyupgrade --py36-plus $(find . -name "*.py") --keep-mock
Using local branch fixes for:
  - mixed mapping/plain printf types
  - Applying %d refactoring for int/len calls instead of just agressive mode
  - Prevent partial conversions when some specifiers not understood
  - Handle '-' and ' ' conversion flags

  flynt .
@graeme-winter
Copy link
Contributor

Change set looks good to me. Assuming there are no objections I would be tempted to merge this ~ ASAP and watch very carefully for any unexpected problems. Scanned the first ~ 20% quite carefully, next 40% very lightly, but assuming this is a bulk change (which it looks like, changes were duplicated) would be very keen on seeing this go in.

@codecov
Copy link

codecov bot commented Jan 26, 2021

Codecov Report

Merging #1567 (f0b62fb) into master (fa83ed1) will decrease coverage by 0.17%.
The diff coverage is 72.62%.

@@            Coverage Diff             @@
##           master    #1567      +/-   ##
==========================================
- Coverage   66.72%   66.55%   -0.18%     
==========================================
  Files         616      614       -2     
  Lines       69290    68682     -608     
  Branches     9572     9562      -10     
==========================================
- Hits        46234    45711     -523     
+ Misses      21120    21044      -76     
+ Partials     1936     1927       -9     

@phyy-nx
Copy link
Member

phyy-nx commented Feb 12, 2021

Hi, here are the xfel_regression test instructions:
https://github.com/cctbx/cctbx_project/tree/master/xfel/conda_envs

Look under the General build instructions, then skip down below to the cctbx.xfel tests section.

@graeme-winter
Copy link
Contributor

Hi, here are the xfel_regression test instructions:
https://github.com/cctbx/cctbx_project/tree/master/xfel/conda_envs

Look under the General build instructions, then skip down below to the cctbx.xfel tests section.

👍

@graeme-winter
Copy link
Contributor

Hi, here are the xfel_regression test instructions:
https://github.com/cctbx/cctbx_project/tree/master/xfel/conda_envs

Look under the General build instructions, then skip down below to the cctbx.xfel tests section.

$ git lfs pull
$ cd ../uc_metrics
$ git lfs install --local

No instruction for source for uc_metrics 🤔

@graeme-winter
Copy link
Contributor

Hi, here are the xfel_regression test instructions:
https://github.com/cctbx/cctbx_project/tree/master/xfel/conda_envs
Look under the General build instructions, then skip down below to the cctbx.xfel tests section.

$ git lfs pull
$ cd ../uc_metrics
$ git lfs install --local

No instruction for source for uc_metrics 🤔

Found at https://gitlab.com/cctbx/

@graeme-winter
Copy link
Contributor

@phyy-nx on this now, though plenty of tests fail on current master branch of dials ...

libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/LS49/tests/tst_cpu_add_spots_double_precision.py" mono [OK] 66.2s
  Standard error:
    /dls/mx-scratch/gw56/dials-xfel/modules/LS49/sim/step5_pad.py:121: SyntaxWarning: "is" with a literal. Did you mean "=="?
      if add_spots_algorithm is "NKS":
    /dls/mx-scratch/gw56/dials-xfel/modules/LS49/sim/step5_pad.py:124: SyntaxWarning: "is" with a literal. Did you mean "=="?
      elif add_spots_algorithm is "JH":
    /dls/mx-scratch/gw56/dials-xfel/modules/LS49/sim/step5_pad.py:126: SyntaxWarning: "is" with a literal. Did you mean "=="?
      elif add_spots_algorithm is "cuda":
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/LS49/tests/tst_monochromatic_image.py" [OK] 69.4s
  Standard error:
    /dls/mx-scratch/gw56/dials-xfel/modules/LS49/sim/step5_pad.py:121: SyntaxWarning: "is" with a literal. Did you mean "=="?
      if add_spots_algorithm is "NKS":
    /dls/mx-scratch/gw56/dials-xfel/modules/LS49/sim/step5_pad.py:124: SyntaxWarning: "is" with a literal. Did you mean "=="?
      elif add_spots_algorithm is "JH":
    /dls/mx-scratch/gw56/dials-xfel/modules/LS49/sim/step5_pad.py:126: SyntaxWarning: "is" with a literal. Did you mean "=="?
      elif add_spots_algorithm is "cuda":
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/tst_s6dist.py" [FAIL] 4.6s
  Time:  4.62
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/tst_s6dist.py", line 2, in <module>
        from cctbx.uctbx.determine_unit_cell import CS6Dist,CS6Dist_in_G6
    ImportError: cannot import name 'CS6Dist' from 'cctbx.uctbx.determine_unit_cell' (/dls/mx-scratch/gw56/dials-xfel/modules/cctbx_project/cctbx/uctbx/determine_unit_cell/__init__.py)
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/ncdist_stability.py" [FAIL] 4.6s
  Time:  4.64
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/ncdist_stability.py", line 8, in <module>
        from cctbx.uctbx.determine_unit_cell import NCDist,NCDist2017
    ImportError: cannot import name 'NCDist2017' from 'cctbx.uctbx.determine_unit_cell' (/dls/mx-scratch/gw56/dials-xfel/modules/cctbx_project/cctbx/uctbx/determine_unit_cell/__init__.py)
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py" all_2 [FAIL] 1.2s
  Time:  1.22
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 351, in <module>
        tester.run_test(test_id)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 74, in run_test
        executor.run()
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 150, in run
        platform_tag = self.get_platform_tag() if ("postrefine" in self.params and self.params["postrefine"] == True) else ''
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 328, in get_platform_tag
        linux_distribution = distro_checker.linux_distribution(full_distribution_name=False)
    AttributeError: module 'platform' has no attribute 'linux_distribution'
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py" postrefine [FAIL] 1.1s
  Time:  1.11
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 351, in <module>
        tester.run_test(test_id)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 74, in run_test
        executor.run()
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 150, in run
        platform_tag = self.get_platform_tag() if ("postrefine" in self.params and self.params["postrefine"] == True) else ''
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 328, in get_platform_tag
        linux_distribution = distro_checker.linux_distribution(full_distribution_name=False)
    AttributeError: module 'platform' has no attribute 'linux_distribution'

etc...

@graeme-winter
Copy link
Contributor

This is all based on a fresh-as-a-daisy brand new bootstrap on RHEL7

@graeme-winter
Copy link
Contributor

Turns out I was running against Python 3.9 which is possibly a little too cutting edge - however with @ndevenish branch I get the same errors, which I read as a good thing

Rebasing on 3.6 now - thanks for spotting that @Anthchirp

@graeme-winter
Copy link
Contributor

On 3.6.12:

Error: the following jobs returned non-zero exit codes or suspicious stderr output:

libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/tst_s6dist.py" [FAIL] 5.5s
  Time:  5.55
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/tst_s6dist.py", line 2, in <module>
        from cctbx.uctbx.determine_unit_cell import CS6Dist,CS6Dist_in_G6
    ImportError: cannot import name 'CS6Dist'
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/ncdist_stability.py" [FAIL] 5.6s
  Time:  5.56
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/ncdist_stability.py", line 8, in <module>
        from cctbx.uctbx.determine_unit_cell import NCDist,NCDist2017
    ImportError: cannot import name 'NCDist2017'
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py" postrefine [FAIL] 27.0s
  Time: 27.04
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 351, in <module>
        tester.run_test(test_id)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 74, in run_test
        executor.run()
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 201, in run
        self.compare_results_with_reference()
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 224, in compare_results_with_reference
        self.compare_experiments(self.output_expt_file_path, self.reference_expt_file_path)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 247, in compare_experiments
        expts_2 = ExperimentListFactory.from_json_file(file_2, check_format = False)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/dxtbx/model/experiment_list.py", line 700, in from_json_file
        with open(filename, "r") as infile:
    FileNotFoundError: [Errno 2] No such file or directory: '/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/merging_test_data/reference_data/test_postrefine_reference.expt'
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py" all_2 [FAIL] 92.3s
  Time: 92.35
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 351, in <module>
        tester.run_test(test_id)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 74, in run_test
        executor.run()
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 201, in run
        self.compare_results_with_reference()
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 221, in compare_results_with_reference
        self.compare_reflection_data(self.output_merged_data_file_path, self.reference_merged_data_file_path)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 285, in compare_reflection_data
        data_2 = mtz.object(file_2)
    RuntimeError: cctbx Error: MTZ file read error: /dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/merging_test_data/reference_data/test_all_2_all_reference.mtz

I imagine that these were hidden behind the is and platform errors above...

@graeme-winter
Copy link
Contributor

Once more, on the branch, ...

Error: the following jobs returned non-zero exit codes or suspicious stderr output:

libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/tst_s6dist.py" [FAIL] 1.9s
  Time:  1.94
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/tst_s6dist.py", line 2, in <module>
        from cctbx.uctbx.determine_unit_cell import CS6Dist,CS6Dist_in_G6
    ImportError: cannot import name 'CS6Dist'
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/ncdist_stability.py" [FAIL] 2.0s
  Time:  2.01
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/ncdist_stability.py", line 8, in <module>
        from cctbx.uctbx.determine_unit_cell import NCDist,NCDist2017
    ImportError: cannot import name 'NCDist2017'
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py" postrefine [FAIL] 13.3s
  Time: 13.26
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 351, in <module>
        tester.run_test(test_id)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 74, in run_test
        executor.run()
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 201, in run
        self.compare_results_with_reference()
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 224, in compare_results_with_reference
        self.compare_experiments(self.output_expt_file_path, self.reference_expt_file_path)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 247, in compare_experiments
        expts_2 = ExperimentListFactory.from_json_file(file_2, check_format = False)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/dxtbx/model/experiment_list.py", line 700, in from_json_file
        with open(filename, "r") as infile:
    FileNotFoundError: [Errno 2] No such file or directory: '/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/merging_test_data/reference_data/test_postrefine_reference.expt'
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py" all_2 [FAIL] 77.7s
  Time: 77.68
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 351, in <module>
        tester.run_test(test_id)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 74, in run_test
        executor.run()
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 201, in run
        self.compare_results_with_reference()
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 221, in compare_results_with_reference
        self.compare_reflection_data(self.output_merged_data_file_path, self.reference_merged_data_file_path)
      File "/dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/test/command_line/tst_xfel_merge.py", line 285, in compare_reflection_data
        data_2 = mtz.object(file_2)
    RuntimeError: cctbx Error: MTZ file read error: /dls/mx-scratch/gw56/dials-xfel/modules/xfel_regression/merging_test_data/reference_data/test_all_2_all_reference.mtz

-> the same so good to go, in my book

@phyy-nx
Copy link
Member

phyy-nx commented Feb 13, 2021

uc_metrics is pulled in by the xfel builder. Did you use --builder=xfel or --builder=dials? I note the LCLS build instructions use the dials builder. I need to update those to the xfel builder too.

The two failing merging tests are weird. The file was removed a while ago.

Oh! I see what's happening here. The platform tag is not working for this test. Look at tst_xfel_merge's function get_platform_tag. What is this finding for your system?

@phyy-nx
Copy link
Member

phyy-nx commented Feb 13, 2021

More detail, platform instability led us to create 3 versions of our reference datasets. These are the datasets the results of merging are compared to. So there are three files for these tests, labeled _Darwin, _C7 and _C6, for macos and two centos versions. We are dropping centos 6 support soon so this can likely be simplified a bit in the future.

@graeme-winter
Copy link
Contributor

uc_metrics is pulled in by the xfel builder. Did you use --builder=xfel or --builder=dials? I note the LCLS build instructions use the dials builder. I need to update those to the xfel builder too.

The two failing merging tests are weird. The file was removed a while ago.

Oh! I see what's happening here. The platform tag is not working for this test. Look at tst_xfel_merge's function get_platform_tag. What is this finding for your system?

Ah, so what I did was build with the dials bootstrap i.e. the one from ... dials. Not cctbx. Guess that could explain it not picking up some of these nuances.

@phyy-nx assume you ran the tests yourself using the cctbx-type build as well right? Any difference? From what I can tell the changes in this PR make no difference to the outcomes.

@phyy-nx
Copy link
Member

phyy-nx commented Feb 14, 2021

Nope, I haven't ran the xfel_regression tests on this PR. I was hoping they would work in your hands, since that would accomplish both testing this PR and getting xfel_regression used more generally :)

That said, I think get_platform_tag just isn't working on your system. What system is it?

@graeme-winter
Copy link
Contributor

Nope, I haven't ran the xfel_regression tests on this PR. I was hoping they would work in your hands, since that would accomplish both testing this PR and getting xfel_regression used more generally :)

That said, I think get_platform_tag just isn't working on your system. What system is it?

RHEL7 on AMD EPYC

@phyy-nx
Copy link
Member

phyy-nx commented Feb 16, 2021

Hi, can you run this snippet:

import platform
try:
  import distro as distro_checker
except ImportError:
  distro_checker = platform

print(platform.platform())
print(distro_checker.linux_distribution(full_distribution_name=False))

I get:

Linux-3.10.0-693.17.1.el7.x86_64-x86_64-with-centos-7.4.1708-Core
test_platform.py:8: DeprecationWarning: dist() and linux_distribution() functions are deprecated in Python 3.5
  print(distro_checker.linux_distribution(full_distribution_name=False))
('centos', '7.4.1708', 'Core')

@graeme-winter
Copy link
Contributor

cs03r-sc-serv-36 ~ :) $ dials.python
Python 3.8.6 | packaged by conda-forge | (default, Jan 25 2021, 23:21:18) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> try:
...   import distro as distro_checker
... except ImportError:
...   distro_checker = platform
... 
>>> print(platform.platform())
Linux-3.10.0-1160.2.1.el7.x86_64-x86_64-with-glibc2.10
>>> print(distro_checker.linux_distribution(full_distribution_name=False))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'platform' has no attribute 'linux_distribution'

@graeme-winter
Copy link
Contributor

Guess, deprecation a long time ago has now come home to roost...

@phyy-nx
Copy link
Member

phyy-nx commented Feb 16, 2021 via email

@graeme-winter
Copy link
Contributor

Right, distro is the replacement for platform. I've been meaning to bring this up as a new dependency. Here's how to get it for a later python version: conda install -c conda-forge distro Then the snippet should work.

Assertion verified:

Linux-3.10.0-1127.13.1.el7.x86_64-x86_64-with-glibc2.10
('rhel', '7.9', 'Maipo')

@phyy-nx
Copy link
Member

phyy-nx commented Feb 17, 2021

I don't get it. That looks like it should resolve to the tag '_C7'

Like this:

$ libtbx.python -c "from xfel_regression.test.command_line.tst_xfel_merge import test_executor; print(test_executor(None, None).get_platform_tag())"
_C7

Anyway this diff should make the tests run, if you don't mind checking again:

$ git diff
diff --git a/test/command_line/tst_xfel_merge.py b/test/command_line/tst_xfel_merge.py
index a3f29f5..27afc8a 100644
--- a/test/command_line/tst_xfel_merge.py
+++ b/test/command_line/tst_xfel_merge.py
@@ -335,6 +335,7 @@ class test_executor(object):
     elif platform.platform().startswith("Darwin"):
       tag = "_Darwin"

+    if not tag: tag = "_C7" # default to centos7
     return tag

 if __name__ == '__main__':

@graeme-winter
Copy link
Contributor

OK, made the diffs you propose but still find:

libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/tst_s6dist.py" [FAIL] 2.3s
  Time:  2.34
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/tst_s6dist.py", line 2, in <module>
        from cctbx.uctbx.determine_unit_cell import CS6Dist,CS6Dist_in_G6
    ImportError: cannot import name 'CS6Dist' from 'cctbx.uctbx.determine_unit_cell' (/dls/mx-scratch/gw56/dials-xfel/modules/cctbx_project/cctbx/uctbx/determine_unit_cell/__init__.py)
libtbx.python "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/ncdist_stability.py" [FAIL] 2.3s
  Time:  2.34
  Return code: 1
  OKs: 0
  Standard error:
    Traceback (most recent call last):
      File "/dls/mx-scratch/gw56/dials-xfel/modules/uc_metrics/tests/ncdist_stability.py", line 8, in <module>
        from cctbx.uctbx.determine_unit_cell import NCDist,NCDist2017
    ImportError: cannot import name 'NCDist2017' from 'cctbx.uctbx.determine_unit_cell' (/dls/mx-scratch/gw56/dials-xfel/modules/cctbx_project/cctbx/uctbx/determine_unit_cell/__init__.py)

I respectfully assert that this has moved significantly off-topic from the "Python 2 idioms" into debugging your platform variant tests and weird test failures - which are identical with and without the branch being checked out. I feel that I have done (more than) due dilligence with running these tests (which I assume you still have not run yourself?) so I think I would like to see this merged.

I don't mind too much helping you to debug these tests in a separate thread, but not here. I'm confident that the change set @ndevenish proposes is good and will save us from making these changes piecemeal in every subsequent commit we make.

@graeme-winter
Copy link
Contributor

FWIW the default to _C7 tag (?!) did resolve two of the four test failures, so we are left with some NCDist2017 unimportability.

OK, that is rather elementary:

ws133 test :( $ dials.python
Python 3.8.6 | packaged by conda-forge | (default, Jan 25 2021, 23:21:18) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import boost_adaptbx.boost.python as bp
>>> bp.import_ext("determine_unit_cell_ext")
<module 'determine_unit_cell_ext' from '/dls/mx-scratch/gw56/dials-xfel/build/lib/determine_unit_cell_ext.so'>
>>> import determine_unit_cell_ext
>>> print(dir(determine_unit_cell_ext))
['NCDist', 'NCDist_flatten', 'NCDist_matrix', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']

it cannot be imported as it is not there to import

@graeme-winter
Copy link
Contributor

// Contingent upon Andrews-Bernstein NCDist repository
# if HAVE_NCDIST
namespace ncdist2017 {
#include <NCDist.h>
#include <CS6Dist.h>
}

I can only assume that we do not have this -> this is the issue here. Am satisfied that the criteria merging this branch are met.

Copy link
Contributor

@graeme-winter graeme-winter left a comment

Choose a reason for hiding this comment

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

Reviewing the change set these look sane and reasonable - this will save us from making the changes piecemeal across the next (forever) commits so worthwhile. Extensive testing across DIALS and XFEL code bases indicates no change to the test outcomes -> the code is good, please merge.

@ndevenish ndevenish merged commit 11760aa into dials:master Feb 17, 2021
@ndevenish ndevenish deleted the apycalypse branch February 17, 2021 15:11
@phyy-nx
Copy link
Member

phyy-nx commented Feb 17, 2021

Thanks for the due diligence

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.

None yet

4 participants