RIAPS / riaps-pycom

Python implementation of the RIAPS component model
Apache License 2.0
7 stars 8 forks source link

RIAPS gen issues #128

Closed adubey14 closed 5 years ago

adubey14 commented 5 years ago

riaps_gen does not check if the necessary arguments have been provided. Check the following execution for context. The following code should return in an help statement asking for arguments to be passed. Also the code should check if the python interpreter is python3 or not.

riapsdev@riapsvbox:~/riaps-pycom/src$ python3 riaps_gen.py 
Traceback (most recent call last):
  File "riaps_gen.py", line 15, in <module>
    from riaps.gen.gen import main
  File "/home/riapsdev/riaps-pycom/src/riaps/gen/gen.py", line 77
    backup_dir = f"{output_dir}_bak"

Also line 77 in gen.py uses f strings. This was introduced in python 3.6. Hence an execution with an older interpreter will fail. Hence the error above. We should not use any special feature that breaks python3 compatibility from earlier versions.

Actually the f-string syntax is used in other places by the riaps_gen as well. Change it .format syntax

imadari commented 5 years ago

@adubey14 riaps_gen does the check, I just tested: without language specification, without output dir, without model and all of these gave the corresponding error message. Could you please provide the parameters what you tried, I cannot reproduce this error.

@gkarsai or @MMetelko Please correct me if I'm wrong, but as far as I know python 3.6 is the minimum requirement of RIAPS.

adubey14 commented 5 years ago

If that is the case then the program needs to check and issue an error if wrong version of interpreter is used. But I think this restriction is possibly not necessary

Sent from my iPhone

On Dec 19, 2018, at 1:47 PM, Istvan Madari notifications@github.com<mailto:notifications@github.com> wrote:

@adubey14https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fadubey14&data=02%7C01%7Cabhishek.dubey%40vanderbilt.edu%7Cd9027cfce60749c2a49e08d665eac4ee%7Cba5a7f39e3be4ab3b45067fa80faecad%7C0%7C0%7C636808456335955359&sdata=cx7IsqL%2FYsutZ8Vvc%2BkMREl60MsEPMwkjypHpyVL%2FQE%3D&reserved=0 riaps_gen does the check, I just tested: without language specification, without output dir, without model and all of these gave the corresponding error message. Could you please provide the parameters what you tried, I cannot reproduce this error.

@gkarsaihttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgkarsai&data=02%7C01%7Cabhishek.dubey%40vanderbilt.edu%7Cd9027cfce60749c2a49e08d665eac4ee%7Cba5a7f39e3be4ab3b45067fa80faecad%7C0%7C0%7C636808456335955359&sdata=R53G73zz5JL72ZFzEY673GrQQWGHo1IfmwGnnbHf7NM%3D&reserved=0 or @MMetelkohttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMMetelko&data=02%7C01%7Cabhishek.dubey%40vanderbilt.edu%7Cd9027cfce60749c2a49e08d665eac4ee%7Cba5a7f39e3be4ab3b45067fa80faecad%7C0%7C0%7C636808456335965368&sdata=VPZ1h9l4ff2xWlOOuRbXcBmhgQOFuYcqcBGrsHvCTRw%3D&reserved=0 Please correct me if I'm wrong, but as far as I know python 3.6 is the minimum requirement of RIAPS.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FRIAPS%2Friaps-pycom%2Fissues%2F128%23issuecomment-448721341&data=02%7C01%7Cabhishek.dubey%40vanderbilt.edu%7Cd9027cfce60749c2a49e08d665eac4ee%7Cba5a7f39e3be4ab3b45067fa80faecad%7C0%7C0%7C636808456335975378&sdata=dZaGx7Ze80bw872jNm%2B%2F5yCPHvWKVLWptX9Z8r7fbDA%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAIF2YxGei0f3YtPCdFV_MSHUzmcGqmJBks5u6pe-gaJpZM4Za45Q&data=02%7C01%7Cabhishek.dubey%40vanderbilt.edu%7Cd9027cfce60749c2a49e08d665eac4ee%7Cba5a7f39e3be4ab3b45067fa80faecad%7C0%7C0%7C636808456335975378&sdata=TgdXJpwPZOHfYa2wey6XRgWirFTqscjmivLyadeMtEU%3D&reserved=0.

imadari commented 5 years ago

If that is the case then the program needs to check and issue an error if wrong version of interpreter is used. But I think this restriction is possibly not necessary

Yep, I've just implemented it.

I'm more concerned about the first issue. May you remember the arguments?

adubey14 commented 5 years ago

You are right that the required=True check should take care of the minimum required arguments issue. I think the problem came on my side during the import. The code never reached main. I will check this with python 3.6 again.

adubey14 commented 5 years ago

Some other things. It will be good to be able to implement generation for any one component from the json. Also if no language is provided and no component is selected then assume all languages and all components. This will help with the dsml. The current behavior is below.

riaps@riaps-devbox:~/temp/abtemp$ riaps_gen -m WeatherMonitor.json 
Language not specified for component:  **[this should say what components have not been specified -- anyways I think with the default assumption of all component and all languages we will have no problem.**
riaps@riaps-devbox:~/temp/abtemp$ riaps_gen -m WeatherMonitor.json -py 
Language not specified for component: 
riaps@riaps-devbox:~/temp/abtemp$ riaps_gen -m WeatherMonitor.json -py oneComp
Language not specified for component: 
riaps@riaps-devbox:~/temp/abtemp$ riaps_gen -m WeatherMonitor.json -py TempMonitor
Language not specified for component: 
riaps@riaps-devbox:~/temp/abtemp$ riaps_gen -m WeatherMonitor.json -py TempMonitor -o .
Language not specified for component:
riaps@riaps-devbox:~/temp/abtemp$ riaps_gen -m WeatherMonitor.json -py TempMonitor TempSensor -o .
imadari commented 5 years ago

obsolote: languages are defined in the riaps model not in the argument list