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

ssx_integrate: catch ValueError #2349

Merged
merged 4 commits into from
Feb 28, 2023
Merged

Conversation

rjgildea
Copy link
Contributor

A ValueError occasionally arise from rstbx parameter_reduction on setting the orientation

A ValueError occasionally arise from rstbx parameter_reduction
on setting the orientation
@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Merging #2349 (cee81ec) into main (e23117f) will decrease coverage by 0.04%.
The diff coverage is 55.55%.

❗ Current head cee81ec differs from pull request most recent head c017430. Consider uploading reports for the commit c017430 to get more accurate results

@@            Coverage Diff             @@
##             main    #2349      +/-   ##
==========================================
- Coverage   83.10%   83.07%   -0.04%     
==========================================
  Files         593      593              
  Lines       68542    68548       +6     
  Branches     9213     9213              
==========================================
- Hits        56965    56944      -21     
- Misses       9445     9474      +29     
+ Partials     2132     2130       -2     

Copy link
Contributor

@jbeilstenedmands jbeilstenedmands left a comment

Choose a reason for hiding this comment

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

Do you know at which precise point the ValueError can be raised? I think my preference would be to catch at the precise call and reraise as a RuntimeError, to avoid hiding any other potential failures/bugs that may cause ValueErrors.

@rjgildea
Copy link
Contributor Author

Do you know at which precise point the ValueError can be raised? I think my preference would be to catch at the precise call and reraise as a RuntimeError, to avoid hiding any other potential failures/bugs that may cause ValueErrors.

Running:

$ cat run.sh
module load dials/latest
xia2.ssx template=/path/to/images_#####.cbf \
  reference_geometry=/path/to/reference_geometry.expt \
  unit_cell=<unit_cell> \
  space_group=P222

gives the following traceback:

multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/conda_base/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/conda_base/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/build/../modules/dials/src/dials/command_line/ssx_integrate.py", line 251, in wrap_integrate_one
    expt, refls, collector = process_one_image(
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/build/../modules/dials/src/dials/command_line/ssx_integrate.py", line 174, in process_one_image
    experiment, table, collector = integrator.run(experiment, table)
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/integration/ssx/ellipsoid_integrate.py", line 110, in run
    experiment, table, refiner_output = self.refine(
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/integration/ssx/ellipsoid_integrate.py", line 184, in refine
    expts, refls, output_data = run_ellipsoid_refinement(
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/algorithm.py", line 461, in run_ellipsoid_refinement
    _ = refine_crystal(
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/algorithm.py", line 342, in refine_crystal
    refiner.refine()
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/refiner.py", line 899, in refine
    self.refine_fisher_scoring()
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/refiner.py", line 928, in refine_fisher_scoring
    self.ml.solve()
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/refiner.py", line 597, in solve
    x = self.gradient_search(x0)
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/refiner.py", line 660, in gradient_search
    return gradient_descent(f, df, x0, max_iter=1, tolerance=self.tolerance)
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/refiner.py", line 544, in gradient_descent
    p = -matrix.col(df(x0))
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/refiner.py", line 658, in df
    return -self.score(x)
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/refiner.py", line 733, in score
    self.model.active_parameters = x
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/parameterisation.py", line 560, in active_parameters
    self.B_params = temp
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/profile_model/ellipsoid/parameterisation.py", line 465, in B_params
    self._B_parameterisation.set_param_vals(tuple(float(i) for i in params))
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/refinement/parameterisation/model_parameters.py", line 255, in set_param_vals
    self.compose()
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/refinement/parameterisation/crystal_parameters.py", line 206, in compose
    newB, self._dstate_dp = self._compose_core([p.value for p in self._param])
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/dials/src/dials/algorithms/refinement/parameterisation/crystal_parameters.py", line 135, in _compose_core
    S.set_orientation(orientation=self._model.get_B())
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/modules/cctbx_project/rstbx/symmetry/constraints/parameter_reduction.py", line 38, in set_orientation
    self.orientation = which_setting[select.index(True)]
ValueError: True is not in list
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/build/../modules/dials/src/dials/command_line/ssx_integrate.py", line 482, in <module>
    run()
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/conda_base/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/build/../modules/dials/src/dials/command_line/ssx_integrate.py", line 428, in run
    for i, (int_expt, int_refl, aggregator) in enumerate(
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/build/../modules/dials/src/dials/command_line/ssx_integrate.py", line 360, in run_integration
    integrated_experiments, integrated_reflections = process_batch(
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/build/../modules/dials/src/dials/command_line/ssx_integrate.py", line 309, in process_batch
    results: List[IntegrationResult] = pool.map(
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/conda_base/lib/python3.10/multiprocessing/pool.py", line 367, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/dls/science/groups/scisoft/DIALS/CD/latest/dials-dev20230224/conda_base/lib/python3.10/multiprocessing/pool.py", line 774, in get
    raise self._value
ValueError: Please report this error to dials-support@lists.sourceforge.net: True is not in list

@jbeilstenedmands
Copy link
Contributor

Verified the above fix on the data in question

@jbeilstenedmands jbeilstenedmands enabled auto-merge (squash) February 28, 2023 12:19
@jbeilstenedmands jbeilstenedmands merged commit e3e05ed into main Feb 28, 2023
@jbeilstenedmands jbeilstenedmands deleted the ssx-integrate-catch-valueerror branch February 28, 2023 13:27
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

3 participants