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

Deprecate petablint with individual tables #274

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Deprecated petablint with individual tables
  • Loading branch information
dweindl committed Jun 25, 2024
commit 9f68596293628438c9a91d3f68c690b6ce3ad0f1
46 changes: 33 additions & 13 deletions petab/petablint.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,35 @@ def parse_cli_args():
)

# Call with set of files
parser.add_argument(
group = parser.add_argument_group("Check individual files *DEPRECATED*")
dweindl marked this conversation as resolved.
Show resolved Hide resolved
group.add_argument(
"-s", "--sbml", dest="sbml_file_name", help="SBML model filename"
)
parser.add_argument(
group.add_argument(
"-o",
"--observables",
dest="observable_file_name",
help="Observable table",
)
parser.add_argument(
group.add_argument(
"-m",
"--measurements",
dest="measurement_file_name",
help="Measurement table",
)
parser.add_argument(
group.add_argument(
"-c",
"--conditions",
dest="condition_file_name",
help="Conditions table",
)
parser.add_argument(
group.add_argument(
"-p",
"--parameters",
dest="parameter_file_name",
help="Parameter table",
)
parser.add_argument(
group.add_argument(
"--vis",
"--visualizations",
dest="visualization_file_name",
Expand All @@ -87,13 +88,18 @@ def parse_cli_args():
group.add_argument(
"-y",
"--yaml",
dest="yaml_file_name_deprecated",
help="PEtab YAML problem filename. "
"*DEPRECATED* pass the file name as positional argument instead.",
)
group.add_argument(
dest="yaml_file_name",
help="PEtab YAML problem filename",
nargs="?",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's possible to say yaml_file_name_deprecated takes 0 arguments, i.e. it's treated as just a "flag", and instead its argument then gets treated as a positional argument, and hence saved to yaml_file_name. Anyway, not important

Copy link
Member Author

@dweindl dweindl Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be done and would slightly simplify the code, but the petablint --help output would be more confusing, I think.

)

args = parser.parse_args()

if args.yaml_file_name and any(
if (args.yaml_file_name or args.yaml_file_name_deprecated) and any(
(
args.sbml_file_name,
args.condition_file_name,
Expand All @@ -102,24 +108,37 @@ def parse_cli_args():
)
):
parser.error(
"When providing a yaml file, no other files may " "be specified."
"When providing a yaml file, no other files may be specified."
)

if args.yaml_file_name_deprecated:
logger.warning(
"The -y/--yaml option is deprecated. "
"Please provide the YAML file as a positional argument."
)
if args.yaml_file_name:
parser.error(
"Please provide only one of --yaml or positional argument."
)

args.yaml_file_name = args.yaml_file_name or args.yaml_file_name_deprecated

return args


def main():
"""Run PEtab validator"""
args = parse_cli_args()
init_colorama(autoreset=True)

ch = logging.StreamHandler()
ch.setFormatter(LintFormatter())
logging.basicConfig(level=logging.DEBUG, handlers=[ch])

args = parse_cli_args()

if args.verbose:
ch.setLevel(logging.DEBUG)
else:
ch.setLevel(logging.WARN)
ch.setFormatter(LintFormatter())
logging.basicConfig(level=logging.DEBUG, handlers=[ch])

if args.yaml_file_name:
from jsonschema.exceptions import ValidationError
Expand All @@ -143,6 +162,7 @@ def main():
problem = petab.Problem.from_yaml(args.yaml_file_name)

else:
# DEPRECATED
logger.debug("Looking for...")
if args.sbml_file_name:
logger.debug(f"\tSBML model: {args.sbml_file_name}")
Expand Down