reproducible-reporting / reprepbuild

Build tool for Reproducible Reporting
GNU General Public License v3.0
1 stars 1 forks source link

The string '1_00' will be converted to the integer number 100 #5

Closed yingxingcheng closed 1 year ago

yingxingcheng commented 1 year ago

https://github.com/reproducible-reporting/reprepbuild/blob/1375ed84c5f098f77b523cd12dae953d5eb93d8b/src/reprepbuild/pythonscript.py#L53-L60

The function potentially creates a problem if the user passes a script argument like 1_00, and it will be converted to the integer 100.

tovrstra commented 1 year ago

Thanks for bringing this up. I'll take a look.

tovrstra commented 1 year ago

A workaround could be to change the conventions used for the arguments passed to the scripts, e.g. prefix with a few letters that would make your argument impossible to interpret as an integer, e.g. Y1_00 (I'm guessing your digits represent indexes of spherical harmonics.)

In principle, we could use less ambiguous representations of the arguments passed to rr-python-script, e.g. with base64 encoded JSON.

For you example, that would mean base64.urlsafe_b64encode(json.dumps("1_00").encode("utf-8")).decode("ascii"), which results in 'IjFfMDAi'. This can be safely passed as a command-line argument in bash and ninja, and can be converted back to its original value. There are some downsides to this approach:

tovrstra commented 1 year ago

I'm going to close this since the workaround seems to work. 1_00 is a valid integer in Python, so adding an exception for this would not be very robust.