Skip to content

Commit

Permalink
Implement a CLI option to set the seed for random number generation (#…
Browse files Browse the repository at this point in the history
…2096)

* Implement a CLI option to set the seed for random number generation.

* No need for f"".
  • Loading branch information
merkys authored Jun 16, 2024
1 parent 3249689 commit e6d6f6f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions optimade/validator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def validate(): # pragma: no cover
import argparse
import json
import os
import random
import sys
import traceback

Expand Down Expand Up @@ -120,6 +121,13 @@ def validate(): # pragma: no cover
help=f"Read timeout to use for each individual request (DEFAULT: {DEFAULT_READ_TIMEOUT} s)",
)

parser.add_argument(
"--random-seed",
type=int,
default=None,
help="Set seed for random number generator for reproducible runs.",
)

args = vars(parser.parse_args())

if os.environ.get("OPTIMADE_VERBOSITY") is not None:
Expand All @@ -146,6 +154,9 @@ def validate(): # pragma: no cover
"The `--page_limit` flag is now deprecated and will not be used by the validator."
)

if args["random_seed"] is not None:
random.seed(args["random_seed"])

validator = ImplementationValidator(
base_url=args["base_url"],
verbosity=args["verbosity"],
Expand Down

0 comments on commit e6d6f6f

Please sign in to comment.