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

Calculations: Python built-in functions not available #554

Closed
grulisco opened this issue Jan 9, 2018 · 6 comments
Closed

Calculations: Python built-in functions not available #554

grulisco opened this issue Jan 9, 2018 · 6 comments

Comments

@grulisco
Copy link
Contributor

grulisco commented Jan 9, 2018

Steps to reproduce

Create or edit a calculation
Use a python function like round(123.123,1) or any other built-in function
(see https://docs.python.org/2/library/functions.html)

Current behavior

error in the test result area:

Unspecified exception: name 'round' is not defined

Expected behavior

Show the calculated result.

Note:
Senaite supports python-syntax in calculations. Arithmetic (+-*/), logical (... if ... else ...) and string operators are working properly as I can see.
We can address functions in python modules (e.g. math) or are able to develop own functions in a separate calculations module.
It seems incomprehensible that pythons built-in functions are unusable as a exception.

@ramonski did a workaround and encapsuled my desired function in our module, but this should work without doing this in advance.
Mostly LabManagers should be able to create calculations and logic inside the LIMS without having admin access to the plone installation.

@ramonski
Copy link
Contributor

Hi @grulisco, I think we fixed that already in #457. Did you encounter this issue on your server or on https://senaite.ridingbytes.com

@grulisco
Copy link
Contributor Author

Hello @ramonski, #457 was another problem with calling functions in modules, that were available while testing in calc setup but not in real ASs IIRC.
This topic was our single issue https://github.com/ridingbytes/liscon.lims/issues/35.
This fundamental problem still persist on https://senaite.ridingbytes.com (see Calculation "python builtin test".
IMHO it is a bug, as it doesn't work as one would expect, but with low priority, as workarounds exist.
Let's improve senaite as far as possible 😄

@grulisco
Copy link
Contributor Author

grulisco commented Jan 18, 2018

Cool done @ramonski, but one question though:
#580 does not handle builtins in general but predefines a few important functions, right?
So if one needs e.g. abs() or min(), it should be easy to extend the code by those?
I quite consider to use string functions for some purposes in the future...

@ramonski
Copy link
Contributor

Yes, you're right, I missed some of the __builtin__'s. I'll reopen that one with the task to add the following as well:

  • sum
  • pow
  • min
  • filter
  • abs
  • any
  • long
  • set

Not sure if we can have lamdba functions...

@grulisco
Copy link
Contributor Author

grulisco commented Feb 2, 2018

Please add

  • str

@ramonski
Copy link
Contributor

ramonski commented Mar 7, 2018

Most of the Python standard builtins added

@ramonski ramonski closed this as completed Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants