Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cleaner check of the number of experiments #16

Open
fretchen opened this issue Dec 15, 2021 · 1 comment
Open

Cleaner check of the number of experiments #16

fretchen opened this issue Dec 15, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@fretchen
Copy link
Contributor

Right now we are checking the number of experiments in an utterly obscure fashion namely through:

try:
            exp_ok = (
                expr.startswith("experiment_")
                and expr[11:].isdigit()
                and (int(expr[11:]) <= max_exps)
            )
        except:
            exp_ok = False
            break

It is completely impossible to know what is going on there...

@fretchen fretchen added enhancement New feature or request help wanted Extra attention is needed labels Dec 15, 2021
@RohitPrasadBhatt
Copy link
Collaborator

RohitPrasadBhatt commented Dec 19, 2021

So:

  • expr.startswith("experiment_") checks if the experiment name starts with "experiment_".
  • The other two conditions check if the suffix is a valid digit in correct range.

If any of those checks fail due to mismatch or an exception the boolean flag is set to false.

Maybe regex can make it a bit slim. Something like ^experiment_[0-9]+$. Caution : verify the expression before using it and set bounds for maximum experiments properly.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants