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

Error on pych --compile #78

Open
buddha314 opened this issue Aug 3, 2017 · 15 comments
Open

Error on pych --compile #78

buddha314 opened this issue Aug 3, 2017 · 15 comments

Comments

@buddha314
Copy link

I have two files.

call.py

from pych.extern import Chapel

@Chapel(sfile='./response.chpl')
def shout_out():
    return None

if __name__=="__main__":
    shout_out()

and response.chpl

module Response{
  export
  proc shout_out() {
        writeln("HI DEE HI DEE HI DEE HI!");
  }
}

They are next to each other in the same directory. I have sourced the SubGenius' venv.sh as in this ticket: #75

When I was least expecting it, I got attacked by an error log:

(pychapel) >  pych --compile response.chpl

Compile this False
Traceback (most recent call last):
  File "/home/buddha314/.virtualenvs/pychapel/bin/pych", line 210, in <module>
    retval = cmd_exec(cmd_args)
  File "/home/buddha314/.virtualenvs/pychapel/bin/pych", line 26, in inner
    return func(*args, **kwargs)
  File "/home/buddha314/.virtualenvs/pychapel/bin/pych", line 98, in compile
    (source_file, output_file, wrap_fp) = moduralize(sfile)
  File "/home/buddha314/.virtualenvs/pychapel/local/lib/python2.7/site-packages/pych/compiler.py", line 193, in moduralize
    source = chpl_spizer.load(source_file)      # Load source-file source
  File "/home/buddha314/.virtualenvs/pychapel/local/lib/python2.7/site-packages/pych/specializer.py", line 83, in load
    path = self.abs_path(filename)
  File "/home/buddha314/.virtualenvs/pychapel/local/lib/python2.7/site-packages/pych/specializer.py", line 61, in abs_path
    if os.path.isabs(filename): # Absolute, just use it.
  File "/home/buddha314/.virtualenvs/pychapel/lib/python2.7/posixpath.py", line 54, in isabs
    return s.startswith('/')
AttributeError: 'bool' object has no attribute 'startswith'

I blame myself, really... But PyChapel may have a bug in it.

@lydia-duncan
Copy link
Member

Yeah, that's definitely a limitation. It currently likes its sfiles to live in a separate directory with sfile in the path name

@buddha314
Copy link
Author

Sounds like it more than "likes" it, sounds like it DEMANDS it... brat. Okay, is the solution to then do..?

src/python/call.py
src/chpl/sfile.response.chpl

@buddha314
Copy link
Author

Computer says "No"

pych --compile chpl/sfile.response.chpl
Compile this False
Traceback (most recent call last):
  File "/home/buddha314/.virtualenvs/pychapel/bin/pych", line 210, in <module>
    retval = cmd_exec(cmd_args)
  File "/home/buddha314/.virtualenvs/pychapel/bin/pych", line 26, in inner
    return func(*args, **kwargs)
  File "/home/buddha314/.virtualenvs/pychapel/bin/pych", line 98, in compile
    (source_file, output_file, wrap_fp) = moduralize(sfile)
  File "/home/buddha314/.virtualenvs/pychapel/local/lib/python2.7/site-packages/pych/compiler.py", line 193, in moduralize
    source = chpl_spizer.load(source_file)      # Load source-file source
  File "/home/buddha314/.virtualenvs/pychapel/local/lib/python2.7/site-packages/pych/specializer.py", line 83, in load
    path = self.abs_path(filename)
  File "/home/buddha314/.virtualenvs/pychapel/local/lib/python2.7/site-packages/pych/specializer.py", line 61, in abs_path
    if os.path.isabs(filename): # Absolute, just use it.
  File "/home/buddha314/.virtualenvs/pychapel/lib/python2.7/posixpath.py", line 54, in isabs
    return s.startswith('/')
AttributeError: 'bool' object has no attribute 'startswith'

@lydia-duncan
Copy link
Member

I think you'll want

src/call.py
src/sfile/chpl/sfile.response.chpl

but I'm looking if that's just because I've been writing tests in $LydiasPychapelInstallDir/docs/source/examples/

@lydia-duncan
Copy link
Member

Also, that error looks really similar to #15

@buddha314
Copy link
Author

Computer says "No". What is this, the f'n HAL 9000? Open the pod-bay doors, damn it!

pych -c sfile/chpl/sfile.response.chpl
Compile this False
Traceback (most recent call last):
  File "/home/buddha314/.virtualenvs/pychapel/bin/pych", line 210, in <module>
    retval = cmd_exec(cmd_args)
  File "/home/buddha314/.virtualenvs/pychapel/bin/pych", line 26, in inner
    return func(*args, **kwargs)
  File "/home/buddha314/.virtualenvs/pychapel/bin/pych", line 98, in compile
    (source_file, output_file, wrap_fp) = moduralize(sfile)
  File "/home/buddha314/.virtualenvs/pychapel/local/lib/python2.7/site-packages/pych/compiler.py", line 193, in moduralize
    source = chpl_spizer.load(source_file)      # Load source-file source
  File "/home/buddha314/.virtualenvs/pychapel/local/lib/python2.7/site-packages/pych/specializer.py", line 83, in load
    path = self.abs_path(filename)
  File "/home/buddha314/.virtualenvs/pychapel/local/lib/python2.7/site-packages/pych/specializer.py", line 61, in abs_path
    if os.path.isabs(filename): # Absolute, just use it.
  File "/home/buddha314/.virtualenvs/pychapel/lib/python2.7/posixpath.py", line 54, in isabs
    return s.startswith('/')
AttributeError: 'bool' object has no attribute 'startswith'

@buddha314
Copy link
Author

What is old is new again...

@lydia-duncan
Copy link
Member

You know, I haven't tried pych --compile in a really long time. I tend to just python compile and blow away the .chpl file when I need to. Should probably have a test script that ran that guy when it worked (if it worked 3 years ago?)

@lydia-duncan
Copy link
Member

You are finding so many things I forgot about!

@buddha314
Copy link
Author

It changes the room when actual users walk in... I get the same thing every time we deploy to production, I hide under my desk.

@buddha314
Copy link
Author

buddha314 commented Aug 3, 2017

I moved the file to a sub directory. Here is my new call.py

import os
from pych.extern import Chapel

currentloc = os.path.dirname(os.path.realpath(__file__))

@Chapel(sfile=os.path.join(currentloc + '/sfile/chpl/sfile.response.chpl'))
def shout_out():
    return None

if __name__=="__main__":
    shout_out()

And then I skipped pych -c and went straight to python call.py. It worked! Now I'm going to try to modify the .chpl file and see what breaks next.

@buddha314
Copy link
Author

Well, all right! I have new files. Using the two below, just running python call.py works. When I modify response.chpl the updated version gets executed. With this in mind, I don't know when I would need to compile them first with pych. I think for what I need, I'll just run with the python command.

Also running the first time is slow, second time much faster.

reponse.chpl

module Response{
  export
  proc shout_out() {
        writeln("HI DEE HI DEE HI DEE HI!");
        writeln("HO DEE HO DEE HO DEE HO!");
        writeln("YIPPIDITY DIPPITIY DEE DAAAA!");
  }
}

call.py

import os
from pych.extern import Chapel

currentloc = os.path.dirname(os.path.realpath(__file__))

# @Chapel(sfile=os.path.join(currentloc + '/sfile/chpl/sfile.response.chpl'))
@Chapel(sfile=os.path.join(currentloc + '/response.chpl'))
def shout_out():
    return None

if __name__=="__main__":
    shout_out()

@lydia-duncan
Copy link
Member

Excellent! We should still fix the pych --compile command, but I'm glad you are able to make progress!

@buddha314
Copy link
Author

when / why should we compile vs just run it via python? Sorry if this is a stupid question.

@lydia-duncan
Copy link
Member

Considering I forgot it existed, I'm not sure if I really know the answer to that one, haha

I would imagine it would be beneficial to do the compile on the .chpl file if you anticipate it being needed for multiple python programs, or if you don't intend to alter it again (and maybe wanted to run that compile while you were still modifying your python file?)

For the most part, I tend to just run it via python, though.

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

No branches or pull requests

2 participants