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

Parse error in open-sir CLI using Windows cmd command line #30

Open
felipehuerta17 opened this issue Apr 7, 2020 · 11 comments
Open

Parse error in open-sir CLI using Windows cmd command line #30

felipehuerta17 opened this issue Apr 7, 2020 · 11 comments

Comments

@felipehuerta17
Copy link
Contributor

A good amount of Python users who use Windows as their operating system have Python installed using Anaconda. By default, the Anaconda Prompt is a cmd shell and most python commands are run in the conda environment embedded in a cmd shell.

When trying to use the open-sir CLI in windows cmd

pipenv run python open-sir.py -p '[0.95,0.38]' -i '[341555,445,0]' -t 6

An error is obtained

Traceback (most recent call last):
  File "open-sir.py", line 39, in <module>
    run_cli()
  File "open-sir.py", line 35, in run_cli
    sol.set_params(p, w0).solve(**kwargs).export(sys.stdout)
  File "C:\open-sir\models\sir.py", line 60, in set_params
    self._set_params(p, initial_conds)
  File "C:\open-sir\models\model.py", line 54, in _set_params
    if len(p) != num_params or len(initial_conds) != num_ic:
TypeError: len() of unsized object

@jia200x thinks that this is caused because of not making the CLI full POSIX.

I haven't tried this in Powershell, but the issue is persistent on cmd.

@felipehuerta17
Copy link
Contributor Author

Hi all,

I tried the above on anaconda prompt in Powershell with my new laptop and works fine. It is something related to windows cmd.

@jia200x
Copy link
Contributor

jia200x commented Apr 8, 2020

I think this happens because of the ugly input format for the parameters. That's absolutely not portable.

Maybe we should think of an input file?

@sasalatart
Copy link
Contributor

@jia200x If that is the case, I think we should support both options. If no parameters are found, then assume it is in a file, or something like that?

@felipehuerta17
Copy link
Contributor Author

@gwenzel had an installation issue with pipenv.

For some reason his local version added a package python==3.7 and that raised an installation error. We should keep an eye on it.

@jia200x
Copy link
Contributor

jia200x commented Apr 10, 2020

@jia200x If that is the case, I think we should support both options. If no parameters are found, then assume it is in a file, or something like that?
I read this comment a little bit late, sorry :(

I'm using for now an "input param" file that can be read from STDIN or a CLI param (see #34 ).
If we need to add these params to the CLI args (as @sasalatart proposes), we can indeed do it.

@jia200x
Copy link
Contributor

jia200x commented Apr 14, 2020

@felipehuerta17 is this issue still present?

@felipehuerta17
Copy link
Contributor Author

felipehuerta17 commented Apr 19, 2020

@jia200x made an excellent improvement on #34.

However, I just realized that our CLI documentation has a small error.

It is not immediately obvious that

usage: opensir-cli [-h] [-m {sir,sirx}] [-t TIME] [-f FILE] [-s] [-d DELIMITER] 

Has to be prefixed by python if it's intended to be run from a CLI.

In the example below,

opensir-cli --model sir --time 6 --file input_file.txt

Will not run (at least in Win10) unless it is called from a Jupyter Notebook or from a python shell. My suggestion is to update the documentation to:

python opensir-cli --model sir --time 6 --file input_file.txt

I just tested again in PS and CMD and works fine as long as python is explicitely mentioned before. I don't know whether the bash preamble enables to run opensir-cli directly on Linux/Mac @jia200x ?

In any case, the full form should be reproducible in all Windows, Linux and Mac

@jia200x
Copy link
Contributor

jia200x commented Apr 19, 2020

Has to be prefixed by python if it's intended to be run from a CLI.

It shouldn't be prefixed with a python command. The CLI is an executable file with a proper python shebang

Will not run (at least in Win10) unless it is called from a Jupyter Notebook or from a python shell.

Did you install the package using pip?

In theory one should be able to do this:

pip install .
open-sir-cli --help

If this is not working under Windows, there's something wrong with the setuptools package and IMO we should fix that instead of updating the documentation. Calling an executable without the python prefix is intended

@jia200x
Copy link
Contributor

jia200x commented Apr 19, 2020

(I'm 100% sure python executables are compatible with Windows. If this is not working, maybe I did something wrong with the package)

@felipehuerta17
Copy link
Contributor Author

felipehuerta17 commented Apr 19, 2020

@jia200x testing:

No luck in PS
image

And CMD just complains

image

@jia200x
Copy link
Contributor

jia200x commented Apr 20, 2020

hmmm there might be something wrong with the deployment setup. I will give it a look.

Thanks for testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants