aig-upf / fs-private

This is the private version of the FS planner repository
GNU General Public License v3.0
5 stars 1 forks source link

ImportError: No module named 'python.parser.f_pddl_plus.fstrips.FunctionalStripsParser' #110

Closed ssardina closed 6 years ago

ssardina commented 6 years ago

Hi @miquelramirez

I installed soplex, set the Hybrid flag to True, run the python parser, all good. But when I ran the example in the readme:

[ssardina@Thinkpad-X1 fs-private.git]$ ./run.py --hybrid --t hybrid_test --instance examples/hybrid/discrete/robot-navigation-num-fn/sample.pddl --driver sbfws --options bfws.rs=sim,bfws.using_feature_set=true,width.force_generic_evaluator=true

********************************************************************************
WARNING! Fixing PYTHONHASHSEED to 1 to obtain more reliable results
********************************************************************************

Problem domain:               robot-navigation-num-fn
Problem instance:             sample
Working directory:            /home/ssardina/git/soft/planning/planning-with-simulators/fs-private.git/workspace/hybrid_test/robot-navigation-num-fn/sample
Traceback (most recent call last):
  File "./run.py", line 17, in <module>
    runner.main(sys.argv[1:])
  File "/home/ssardina/git/soft/planning/planning-with-simulators/fs-private.git/python/parser/runner.py", line 287, in main
    return run(parse_arguments(args))
  File "/home/ssardina/git/soft/planning/planning-with-simulators/fs-private.git/python/parser/runner.py", line 262, in run
    from . import f_pddl_plus
  File "/home/ssardina/git/soft/planning/planning-with-simulators/fs-private.git/python/parser/f_pddl_plus/__init__.py", line 1, in <module>
    from .fstrips.tasks import Task
  File "/home/ssardina/git/soft/planning/planning-with-simulators/fs-private.git/python/parser/f_pddl_plus/fstrips/tasks.py", line 15, in <module>
    from .fs_task_loader import FunctionalStripsLoader
  File "/home/ssardina/git/soft/planning/planning-with-simulators/fs-private.git/python/parser/f_pddl_plus/fstrips/fs_task_loader.py", line 12, in <module>
    from .visitor import FunctionalStripsVisitor
  File "/home/ssardina/git/soft/planning/planning-with-simulators/fs-private.git/python/parser/f_pddl_plus/fstrips/visitor.py", line 4, in <module>
    from .FunctionalStripsParser import FunctionalStripsParser
ImportError: No module named 'python.parser.f_pddl_plus.fstrips.FunctionalStripsParser'

As far as I can tell the command

./build_parser.py --grammar FunctionalStrips.g4 --deploy fstrips

has produced all files correctly...

any suggestion?

miquelramirez commented 6 years ago

Hola Sebastian,

you can only get that error if the parser wasn't generated. Did you install ANLTR4 and its Python 3 bindings as per the instructions I set to you via email?

Cheers,

Miquel.

ssardina commented 6 years ago

I think I did all, but let me check all that again. Clearly there is nothing obvious that you spotted so must be my side... Let me check. Thanks for the quick reply though!

ssardina commented 6 years ago

Actually, I checked and it does seem I have it all setup well: (I try to install python packages via pip always, not manually, which is what I did):

[ssardina@Thinkpad-X1 fs-private.git]$ echo $CLASSPATH
.:/home/ssardina/opt/antlr/antlr-4.7.1-complete.jar:.:/opt/Agent_Software/lib/jack.jar:

[ssardina@Thinkpad-X1 fs-private.git]$ pip2 list | grep antl
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
antlr4-python2-runtime (4.7.1)

[ssardina@Thinkpad-X1 fs-private.git]$ pip3 list | grep antl
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
antlr4-python3-runtime (4.7.1)

And after running the build I have:

[ssardina@Thinkpad-X1 fs-private.git]$ l python/parser/f
f_pddl_plus/           fs_task.py             fstrips_components.py  fstrips.py
[ssardina@Thinkpad-X1 fs-private.git]$ l python/parser/f
f_pddl_plus/           fs_task.py             fstrips_components.py  fstrips.py
[ssardina@Thinkpad-X1 fs-private.git]$ l python/parser/f_pddl_plus/
build_parser.py               FunctionalStripsLexer.tokens  __pycache__/
fstrips/                      FunctionalStrips.tokens       Readme.md
FunctionalStrips.g4           __init__.py                   test_fstrips_parser.py
FunctionalStrips.interp       pddl3/                        
FunctionalStripsLexer.interp  Pddl3.g4                      
[ssardina@Thinkpad-X1 fs-private.git]$ l python/parser/f_pddl_plus/fstrips/
total 624K
drwxrwxr-x 3 ssardina ssardina 4.0K Feb 11 14:44 .
drwxrwxr-x 5 ssardina ssardina 4.0K Feb 11 14:44 ..
-rw-rw-r-- 1 ssardina ssardina  32K Feb 10 14:56 fs_task_loader.py
-rw-rw-r-- 1 ssardina ssardina 1.4K Feb 10 14:56 graph.py
-rw-rw-r-- 1 ssardina ssardina    0 Feb 11 14:44 __init__.py
-rw-rw-r-- 1 ssardina ssardina  45K Feb 11 14:44 lexer.py
-rw-rw-r-- 1 ssardina ssardina  54K Feb 11 14:44 listener.py
-rw-rw-r-- 1 ssardina ssardina 362K Feb 11 14:44 parser.py
drwxrwxr-x 2 ssardina ssardina 4.0K Feb 11 14:44 __pycache__
-rw-rw-r-- 1 ssardina ssardina 9.2K Feb 10 14:56 tasks.py
-rw-rw-r-- 1 ssardina ssardina  32K Feb 11 14:44 visitor.py

This was generated by:

[ssardina@Thinkpad-X1 f_pddl_plus]$ pwd
/home/ssardina/git/soft/planning/planning-with-simulators/fs-private.git/python/parser/f_pddl_plus
[ssardina@Thinkpad-X1 f_pddl_plus]$ ./build_parser.py --grammar FunctionalStrips.g4 --deploy fstrips
Generated files prefix: FunctionalStrips
fstrips/listener.py
fstrips/lexer.py
[('from FunctionalStripsListener', 'from listener'), ('from .FunctionalStripsListener', 'from .listener'), ('from FunctionalStripsVisitor', 'from visitor'), ('from .FunctionalStripsVisitor', 'from .visitor')]
Replaced old module names
fstrips/parser.py
fstrips/visitor.py
[ssardina@Thinkpad-X1 f_pddl_plus]$ 

is there a missing file FunctionalStripsParser.py that is not being produced in python/parser/f_pddl_plus?

But, hold on now. Instructions say:

_"In order to build the parsers, get into the antlr4parsers folder and issue the command:"

and there is no "antlr4_parser", I am doing this in another dir... Should I be using another branch, not v2? ahhh maybe that is it...

miquelramirez commented 6 years ago

Hola @ssardina ,

if you're using the v2 branch you don't need to regenerate the parser, you just need antlr4 installed. Since this version of FS depends on Python 3, you need to install the Python3 bindings for antlr4.

The passage

"In order to build the parsers, get into the antlr4_parsers folder and issue the command:"

is deprecated - we changed the layout of the parsers a while ago.

All of the above seems to me unrelated to the original issue. Checking the visitor.py file we have on the sources, I can't find the import command that caused the problem in your system.

Could you please discard any local changes you have under the python/parsers folder and try again?

ssardina commented 6 years ago

Ohh, yes! I deleted the folder completely and checked out the original one from repo and now it runs well!

So, summing up, wrt the instructions in https://github.com/aig-upf/fs-private/blob/v2/python/parser/f_pddl_plus/Readme.md the part

In order to build the parsers, get into the antlr4_parsers folder and issue the command:

$ ./build_parser.py --grammar FunctionalStrips.g4 --deploy fstrips

which will compile the grammar and generate the corresponding Python classes inside the module fstrips

is not applicable anymore?

Thanks!

miquelramirez commented 6 years ago

I need to revise those docs @ssardina, will do sometime this week so I don't forget :)

Enjoy!