ratt-ru / pyxis

Python Extensions for Interferometry Scripting
3 stars 5 forks source link

TypeError: exec() arg 1 must be a string, bytes or code object #100

Closed matthieutrs closed 4 years ago

matthieutrs commented 4 years ago

Hello,

I am trying to use pyxis with loading .conf and .py files. More precisely, I have 2 files (named pyxis-ckat.py and pyxis-ckat.conf) in some folder and I'm autoloading them. Yet I receive the following error message:

2020/07/02 17:19:10 PYXIS: VERBOSE=1 by default
2020/07/02 17:19:10 PYXIS: loading Pyxis into context '__main__'
2020/07/02 17:19:10 PYXIS: auto-loading from .: pyxis-ckat.py pyxis-ckat.conf
Traceback (most recent call last):
  File ".../pyxis/1.7.0/lib/python3.6/site-packages/Pyxis/Internals.py", line 825, in load_package
    exec(open(filename),Pyxis.Context);
TypeError: exec() arg 1 must be a string, bytes or code object
2020/07/02 17:19:10 ABORT: PYXIS: error parsing ./pyxis-ckat.py, see output above and/or log for details

This is a procedure I was using before moving to 1.7.0 and that was working fine, so I doubt that the problem comes from my pyxis-ckat.py and pyxis-ckat.conf files... Would you have any hint on how to solve that?

matthieutrs commented 4 years ago

I also get the same error message when using the .py and .conf files from /Pyxis/doc/example.

o-smirnov commented 4 years ago

Another casualty of the Python3 transition... Sorry, doesn't look like we tested it very well with py3!

Could you try changing the offending statement to

exec open(filename, "rt") in Pyxis.Context

and let me know if that works?

adrianjhpc commented 4 years ago

I'm doing the install for @matthieutrs, should that be: exec open(filename, "rt") in Pyxis.Context; @o-smirnov? Or does python not care?

adrianjhpc commented 4 years ago

open(filename, "rt") in Pyxis.Context; seems to have done the trick

matthieutrs commented 4 years ago

Thanks a lot @o-smirnov and @adrianjhpc, that problem is solved!

I'm facing another one now: the procedures defined in my pyxis-*.py files are unrecognized.

More precisely, I set the pyxis-wsrt21cm.py file from the example in my base directory and I then run pyxis cal_ms. The command returns:

2020/07/03 15:56:11 PYXIS: ===[ Pyxis: Python eXtensions for Inteferometry Scripting (C) 2013 by Oleg Smirnov <oms@ska.ac.za> ]===
2020/07/03 15:56:11 PYXIS: VERBOSE=1 by default
2020/07/03 15:56:11 PYXIS: loading Pyxis into context '__main__'
2020/07/03 15:56:11 PYXIS: auto-loading from .: pyxis-wsrt21cm.py
2020/07/03 15:56:11 PYXIS: auto-loading from .: pyxis-wsrt21cm.py
2020/07/03 15:56:11 PYXIS: running command cal_ms
2020/07/03 15:56:11 ABORT: undefined command 'cal_ms'
2020/07/03 15:56:11 PYXIS:
2020/07/03 15:56:11 INFO: elapsed time is 0h0m0.00s

I don't understand:

Would you have an idea on how to fix that?

bennahugo commented 4 years ago

Apologies I only ported the necessary bits of pyxis to perform the meqtrees tests and didn't extensively test it. I was under impression it was abandonware since we now have switched to things like stimela to pipeline instead.

Please raise issues and I will get back to it when I return from leave.

On Fri, Jul 3, 2020 at 5:05 PM matthieu.trs notifications@github.com wrote:

Thanks a lot @o-smirnov https://github.com/o-smirnov and @adrianjhpc https://github.com/adrianjhpc, that problem is solved!

I'm facing another one now: the procedures defined in my pyxis-*.py files are unrecognized.

More precisely, I set the pyxis-wsrt21cm.py file from the example https://github.com/ska-sa/pyxis/blob/master/Pyxis/doc/example/pyxis-wsrt21cm.py in my base directory and I then run pyxis cal_ms. The command returns:

2020/07/03 15:56:11 PYXIS: ===[ Pyxis: Python eXtensions for Inteferometry Scripting (C) 2013 by Oleg Smirnov oms@ska.ac.za ]=== 2020/07/03 15:56:11 PYXIS: VERBOSE=1 by default 2020/07/03 15:56:11 PYXIS: loading Pyxis into context 'main' 2020/07/03 15:56:11 PYXIS: auto-loading from .: pyxis-wsrt21cm.py 2020/07/03 15:56:11 PYXIS: auto-loading from .: pyxis-wsrt21cm.py 2020/07/03 15:56:11 PYXIS: running command cal_ms 2020/07/03 15:56:11 ABORT: undefined command 'cal_ms' 2020/07/03 15:56:11 PYXIS: 2020/07/03 15:56:11 INFO: elapsed time is 0h0m0.00s

I don't understand:

Would you have an idea on how to fix that?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ska-sa/pyxis/issues/100#issuecomment-653588014, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4RE6SWI4W25GB4JTNZXFLRZXXSTANCNFSM4OPBRNBQ .

--

Benjamin Hugo

PhD. student, Centre for Radio Astronomy Techniques and Technologies Department of Physics and Electronics Rhodes University

Junior software developer Radio Astronomy Research Group South African Radio Astronomy Observatory Black River Business Park Observatory Cape Town

matthieutrs commented 4 years ago

Ok, thanks! I'm raising a new issue as this one has been solved thanks to @o-smirnov and @adrianjhpc.

o-smirnov commented 4 years ago

Not so much abandonware as neglectware... It can still be useful for ad hoc processing scripts, so I'd like to fix it.

Since @bennahugo got most of it to work, I'm sure it's just a few odds and ends that need fixing. I'll take a look.

My fault for not providing proper test coverage in the first place!