mlhubber / mlhub

Machine Learning Model Repository Hub Command Line Tool.
MIT License
20 stars 12 forks source link

Check MLHUB.yaml exists before downloading the repository #194

Closed gjwgit closed 3 years ago

gjwgit commented 3 years ago

When is the check done - it should be done before dowloading the full repo.

We really should not be seeing the traceback dump:

$ ml install fred/random-repo
Your branch is up to date with 'origin/master'.

mlhub: No MLHUB description file found: /tmp/tmp64yfopmh/random-repo
  The model package may be broken!
Traceback (most recent call last):
  File "/home/gjw/.local/lib/python3.8/site-packages/mlhub/__init__.py", line 208, in main
    args.func(args)
  File "/home/gjw/.local/lib/python3.8/site-packages/mlhub/commands.py", line 388, in install_model
    mlhubyaml = utils.get_available_pkgyaml(
  File "/home/gjw/.local/lib/python3.8/site-packages/mlhub/utils.py", line 335, in get_available_pkgyaml
    raise DescriptionYAMLNotFoundException(param)
mlhub.utils.DescriptionYAMLNotFoundException: /tmp/tmp64yfopmh/random-repo

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gjw/.local/bin/ml", line 8, in <module>
    sys.exit(main())
  File "/home/gjw/.local/lib/python3.8/site-packages/mlhub/__init__.py", line 263, in main
    utils.print_commands_suggestions_on_stderr('remove', 'install')
  File "/home/gjw/.local/lib/python3.8/site-packages/mlhub/utils.py", line 776, in print_commands_suggestions_on_stderr
    print_on_stderr(get_command_suggestion(cmd))
  File "/home/gjw/.local/lib/python3.8/site-packages/mlhub/utils.py", line 2559, in print_on_stderr
    print(msg.format(*param), file=sys.stderr)
AttributeError: 'NoneType' object has no attribute 'format'
gjwgit commented 3 years ago

How to get rid of the git message about the branch up to date? Just output the error message on one line.

$ ml install anusii/relm
Your branch is up to date with 'origin/master'.

mlhub: No MLHUB.yaml description file found.
gjwgit commented 3 years ago
$ pip3 install mlhub==3.7.8
...
$ ml readme rain
Predicting Rain

This MLHub package uses the weatherAUS dataset from R’s Rattle package
...

$ pip3 install mlhub==3.7.9
Collecting mlhub==3.7.9
...

$ ml readme rain

mlhub: The 'rain' model does not have a 'README.txt' file.
JingjingShii commented 3 years ago

proc = subprocess.Popen( command, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE ) Basically, this "pipes" whatever cmd outputs to stdout and stderr to in-memory buffers prepared by subprocess. What you do with the content of those buffers are up to you. You can examine them, or don't bother with them altogether. But the side effect of piping to these buffers is that they won't be printed to the terminal

ref: https://stackoverflow.com/questions/4996852/how-to-just-call-a-command-and-not-get-its-output