[Debian-med-packaging] Bug#973013: ctdopts autopkg tests are failing, blocking python3-defaults
Matthias Klose
doko at debian.org
Tue Oct 27 11:58:51 GMT 2020
Package: src:ctdopts
Version: 1.4-1
Severity: serious
Tags: sid bullseye
User: debian-python at lists.debian.org
Usertags: python3.9
autopkgtest [07:37:47]: test run-example: [-----------------------
+ py3versions -r
+ echo Testing with python3.9:
+ python3.9 -c import CTDopts; print(CTDopts)
Testing with python3.9:
<module 'CTDopts' from
'/tmp/autopkgtest-lxc.e7_px4dx/downtmp/build.CLh/src/CTDopts/__init__.py'>
+ python3.9 /usr/share/doc/python3-ctdopts/examples/example.py
Model being written to exampleTool.ctd...
Model loaded from exampleTool.ctd...
For debugging purposes we can output a human readable representation of
Parameter objects. Here's the first one:
PARAMETER positive_int
type: int
default: 5
tags: advanced, magic
restrictions on numeric range: 0 to None
description: A positive integer parameter
The following parameters were registered in the model:
['positive_int', 'input_files', 'output', 'this_that', 'param_1', 'param_2',
'param_3']
The same parameters with subgroup information, if they were registered under
parameter groups:
['positive_int', 'input_files', 'output', 'this_that', 'subparams:param_1',
'subparams:param_2', 'subparams:subsubparam:param_3']
A dictionary of parameters with default values, returned by CTDModel.get_defaults():
{ 'positive_int': 5,
'subparams': { 'param_1': 5.5,
'param_2': [0.0, 2.5, 5.0],
'subsubparam': {'param_3': 2}},
'this_that': 'this'}
As you can see, parameter values are usually stored in nested dictionaries. If
you want a flat dictionary, you canget that using CTDopts.flatten_dict(). Flat
keys can be either tuples of tree node (subgroup) names down to the parameter...
{ ('positive_int',): 5,
('subparams', 'param_1'): 5.5,
('subparams', 'param_2'): [0.0, 2.5, 5.0],
('subparams', 'subsubparam', 'param_3'): 2,
('this_that',): 'this'}
...or they can be strings where nesing levels are separated by colons:
{ 'positive_int': 5,
'subparams:param_1': 5.5,
'subparams:param_2': [0.0, 2.5, 5.0],
'subparams:subsubparam:param_3': 2,
'this_that': 'this'}
We can create dictionaries of arguments on our own that we want to validate
against the model.CTDopts can read them from argument-storing CTD files or from
the command line, but we can just define them in a nested dictionary on our own
as well. We start with defining them explicitly.
{ 'input_files': ['file1.fastq', 'file2.fastq', 'file3.fastq'],
'positive_int': 111,
'subparams': {'param_1': '999.0'}}
We can validate these arguments against the model, and get a dictionary with
parameter types correctly casted and defaults set. Note that subparams:param_1
was casted from string to a floating point number because that's how it was
defined in the model.
{ 'input_files': ['file1.fastq', 'file2.fastq', 'file3.fastq'],
'positive_int': 111,
'subparams': { 'param_1': 999.0,
'param_2': [0.0, 2.5, 5.0],
'subsubparam': {'param_3': 2}},
'this_that': 'this'}
We can write a CTD file containing these validated argument values. Just call
CTDModel.write_ctd() with an extra parameter: the nested argument dictionary
containing the actual values.
As mentioned earlier, CTDopts can load argument values from CTD files. Feel free
to change some values in exampleTool_preset_params.ctd you've just written, and
load it back.
Traceback (most recent call last):
File "/usr/share/doc/python3-ctdopts/examples/example.py", line 165, in <module>
args_from_ctd = args_from_file('exampleTool_preset_params.ctd')
File "/usr/lib/python3/dist-packages/CTDopts/CTDopts.py", line 1230, in
args_from_file
return get_args(parameters, base=None)
File "/usr/lib/python3/dist-packages/CTDopts/CTDopts.py", line 1211, in get_args
get_args(child, current_group)
File "/usr/lib/python3/dist-packages/CTDopts/CTDopts.py", line 1224, in get_args
if element.getchildren():
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute
'getchildren'
autopkgtest [07:37:47]: test run-example: -----------------------]
autopkgtest [07:37:47]: test run-example: - - - - - - - - - - results - - - - -
- - - - -
run-example FAIL non-zero exit status 1
autopkgtest [07:37:48]: @@@@@@@@@@@@@@@@@@@@ summary
run-example FAIL non-zero exit status 1
More information about the Debian-med-packaging
mailing list