Skip to content

Commit

Permalink
Issue tiggerlsm19 (#64)
Browse files Browse the repository at this point in the history
* Fixes astropy error and disentangles qt4 from pipeliner

- fixes tigger-lsm#19
- disentangles pipeliner from qt4

* Default build system is now py3
  • Loading branch information
bennahugo authored Jan 6, 2021
1 parent 061c2e5 commit 29f7821
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 45 deletions.
8 changes: 4 additions & 4 deletions .travis/py2.docker
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ RUN pip install meqtrees-cattery astro-kittens purr astro-tigger-lsm owlcat Pyth
ADD . /code
RUN mkdir /code/build
WORKDIR /code/build
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ../
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON_3=OFF ../
RUN make -j4
RUN make install
RUN ldconfig

# get the test from pyxis
WORKDIR /code
RUN wget https://github.com/ska-sa/pyxis/archive/v1.7.0.tar.gz
RUN tar -xvf v1.7.0.tar.gz
WORKDIR /code/pyxis-1.7.0
RUN wget https://github.com/ska-sa/pyxis/archive/v1.7.1.tar.gz
RUN tar -xvf v1.7.1.tar.gz
WORKDIR /code/pyxis-1.7.1
RUN pip install -U .
RUN flag-ms.py --help
RUN meqtree-pipeliner.py --help
Expand Down
25 changes: 12 additions & 13 deletions .travis/py3.docker
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ RUN docker-apt-install libblitz0-dev python3-dev libblas-dev liblapack-dev libqd
#####################################################################
RUN mkdir /src
WORKDIR /src
RUN wget https://github.com/casacore/casacore/archive/v3.2.1.tar.gz
RUN tar xvf v3.2.1.tar.gz
RUN mkdir casacore-3.2.1/build
WORKDIR /src/casacore-3.2.1/build
RUN echo hello
RUN wget https://github.com/casacore/casacore/archive/v3.3.0.tar.gz
RUN tar xvf v3.3.0.tar.gz
RUN mkdir casacore-3.3.0/build
WORKDIR /src/casacore-3.3.0/build
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_DEPRECATED=ON -DBUILD_PYTHON3=ON -DBUILD_PYTHON=OFF ../
RUN make -j 4
RUN make install
RUN ldconfig
#RUN pip install -U --user --force-reinstall --install-option="--prefix=/usr" pip setuptools wheel
WORKDIR /src
RUN wget https://github.com/casacore/python-casacore/archive/v3.2.0.tar.gz
RUN tar xvf v3.2.0.tar.gz
WORKDIR /src/python-casacore-3.2.0
RUN wget https://github.com/casacore/python-casacore/archive/v3.3.0.tar.gz
RUN tar xvf v3.3.0.tar.gz.1
WORKDIR /src/python-casacore-3.3.0
RUN pip3 install .
WORKDIR /
RUN python3 -c "from pyrap.tables import table as tbl"
Expand Down Expand Up @@ -61,11 +60,11 @@ RUN makems WSRT_makems.cfg
#####################################################################
WORKDIR /src
RUN docker-apt-install git
RUN wget https://github.com/Athanaseus/casarest/archive/1.6.0.tar.gz
RUN tar xvf 1.6.0.tar.gz
WORKDIR /src/casarest-1.6.0
RUN wget https://github.com/casacore/casarest/archive/v1.7.0.tar.gz
RUN tar xvf v1.7.0.tar.gz
WORKDIR /src/casarest-1.7.0
RUN mkdir -p build
WORKDIR /src/casarest-1.6.0/build
WORKDIR /src/casarest-1.7.0/build
RUN cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ../
RUN make -j 4
RUN make install
Expand All @@ -80,7 +79,7 @@ RUN git clone -b v1.5.0 https://github.com/ska-sa/purr.git
RUN git clone -b v1.6.2 https://github.com/ska-sa/owlcat.git
RUN git clone -b v1.4.3 https://github.com/ska-sa/kittens.git
RUN git clone -b v1.6.0 https://github.com/ska-sa/tigger-lsm.git
RUN git clone -b v1.7.0 https://github.com/ska-sa/pyxis.git
RUN git clone -b v1.7.1 https://github.com/ska-sa/pyxis.git

RUN pip3 install ./meqtrees-cattery ./purr ./owlcat ./kittens ./tigger-lsm
RUN pip3 install -e ./pyxis
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
include(cmake/meqmacros.cmake)
include(cmake/mequtils.cmake)

option(ENABLE_PYTHON_3 "Enables support for Python 3.x" OFF)
option(ENABLE_PYTHON_3 "Enables support for Python 3.x" ON)
if ("${ENABLE_PYTHON_3}")
message("-- Compiling backend against Python 3.x")
set(PYREQ_VER 3.0)
Expand Down
8 changes: 4 additions & 4 deletions PyApps/src/Apps/QObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ def PYSIGNAL (sig):
class QObject (object):
"""This is a qt.QObject replacememt for systems with no PyQt.
It supports a simple connect/emit mechanism."""
def __init__ (self,name=None,*args):
def __init__ (self, name=None, *args):
self._name = name;
self._connections = {};
def name (self):
return self._name;

def connect (sender,signal,receiver):
def connect (sender, signal, receiver):
"""Connects named signal of sender to receiver""";
conns = sender._connections.setdefault(signal,[]);
conns.append(receiver);
return True;
connect = staticmethod(connect);

def disconnect (sender,signal,receiver):
def disconnect (sender, signal, receiver):
"""Disconnects named signal of sender from receiver""";
conns = sender._connections.get(signal,None);
if conns:
sender._connections[signal] = [x for x in conns if x!=receiver];
disconnect = staticmethod(disconnect);

def emit (signal,args):
def emit (self, signal, *args):
for receiver in self._connections.get(signal,[]):
receiver(*args);
3 changes: 1 addition & 2 deletions PyApps/src/Apps/meqserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@
try:
from Timba.GUI import meqserver_gui
from Timba.GUI.meqserver_gui import *
except:
except ImportError:
print("*** Error importing GUI modules:");
traceback.print_exc();
pass;

# #-------- update default debuglevels
Expand Down
17 changes: 10 additions & 7 deletions PyApps/src/Apps/multiapp_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,21 @@

from Timba.Apps import app_defaults

if app_defaults.include_gui:
import Timba.GUI.app_proxy_gui;
if app_defaults.args.threads:
import Timba.qt_threading;

try:
from PyQt4.Qt import QObject,SIGNAL
from Kittens.widgets import PYSIGNAL
except:
QT_AVAILABLE = True
except ImportError:
print("Qt not available, substituting proxy types for QObject");
from .QObject import QObject,PYSIGNAL

SIGNAL = PYSIGNAL
QT_AVAILABLE = False

if app_defaults.include_gui and QT_AVAILABLE:
import Timba.GUI.app_proxy_gui;
if app_defaults.args.threads:
import Timba.qt_threading;

from Timba.dmi import *
from Timba import octopussy
Expand Down Expand Up @@ -285,7 +288,7 @@ def _connect_server (self,addr):
self.servers[addr] = server;
self.dprint(2, "requesting state and status update");
self.send_command("Request.State",destination=addr);
self.client.emit(SIGNAL("serverConnected"),server,);
self.client.emit(SIGNAL("serverConnected"),server);
self._gui_event_handler(self.hello_event,addr,server);
self._gui_event_handler(self.server_state_event,record(),server);
# is an auto-attach request in place?
Expand Down
1 change: 0 additions & 1 deletion PyApps/src/Meq/meq.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from Timba.dmi import *

from Timba.array import *
from Timba.Meq import meqds
from Timba import mequtils

domain_ndim = 2;
Expand Down
5 changes: 3 additions & 2 deletions PyApps/src/Meq/meqds.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
import traceback

try:
from PyQt4.Qt import QObject,SIGNAL
from PyQt4.Qt import QObject, SIGNAL
from Kittens.widgets import PYSIGNAL
except:
print("Qt not available, substituting proxy types for QObject");
from Timba.Apps.QObject import QObject,PYSIGNAL
from Timba.Apps.QObject import QObject, PYSIGNAL
SIGNAL = PYSIGNAL

_dbg = verbosity(0,name='meqds');
_dprint = _dbg.dprint;
Expand Down
33 changes: 26 additions & 7 deletions PyApps/src/TDL/Compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import Timba.TDL.Settings
from Timba.TDL import TDLOptions

import imp

import sys
import re
import traceback
Expand All @@ -42,6 +42,9 @@
import six
if six.PY3:
from importlib import reload
import importlib.machinery
#else:
import imp

_dbg = verbosity(0,name='tdlc');
_dprint = _dbg.dprint;
Expand All @@ -66,6 +69,7 @@ def _update_modlist ():
_dprint(1,'TDL run imported',len(_tdlmodlist),"modules:",modlist);
_tdlmodlist = set([name for name in _tdlmodlist
if name != "six" and not name.startswith("six.")
and name != "astropy" and not name.startswith("astropy.")
and not getattr(sys.modules[name],'_tdl_no_reimport',False)]);
modlist = list(_tdlmodlist);
modlist.sort();
Expand All @@ -84,12 +88,11 @@ class CompileError (RuntimeError):
def __init__ (self,*errlist):
self.errlist = errlist;

def import_tdl_module (filename,text=None,config=0):
def import_tdl_module (filename, text=None, config=0):
"""Imports a TDL module.
Parameters:
filename: script location
text: text of module. If none, file will be re-read.
text: if None loads from specified filename
Return value:
a tuple of (module,text), where module is the newly-imported
TDL module, and text is the module text.
Expand Down Expand Up @@ -117,10 +120,18 @@ def import_tdl_module (filename,text=None,config=0):
except:
pass;
# open file
infile = open(filename,'r');
infile = open(filename,'r')
if text is None:
text = infile.read();
infile.seek(0);
# infile = open(filename,'r')
# text = infile.read()
# infile.seek(0)
# else:
# infile = open("./.currenttdl.py", mode='w+b')
# infile.write(text.encode('utf-8'))
# infile.seek(0)

# infile is now an open input file object, and text is the script

# flush all modules imported via previous TDL run
Expand All @@ -135,11 +146,19 @@ def import_tdl_module (filename,text=None,config=0):
modname = '__tdlruntime';
try:
TDLOptions.enable_save_config(False);
imp.acquire_lock();
_tdlmod = imp.load_source(modname,filename,infile);
# if six.PY2:
imp.acquire_lock()
_tdlmod = imp.load_source(modname, filename, infile)
# else:
# import types
# loader = importlib.machinery.SourceFileLoader(modname, filename if text is None else infile.name)
# spec = importlib.util.spec_from_loader(loader.name, loader)
# _tdlmod = importlib.util.module_from_spec(spec)
# loader.exec_module(_tdlmod)
finally:
TDLOptions.enable_save_config(True);
TDLOptions.save_config();
#if six.PY2:
imp.release_lock();
infile.close();
_update_modlist();
Expand Down
12 changes: 8 additions & 4 deletions PyApps/src/TDL/TDLOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

from Timba.dmi import *
from Timba.utils import *
from Timba.GUI.pixmaps import pixmaps
import configparser

import traceback
Expand All @@ -45,9 +44,11 @@
from PyQt4.Qt import *
from Kittens.widgets import PYSIGNAL
OptionObject = QObject();
except:
OptionObject;
pass;
except ImportError:
OptionObject = None
class QFileDialog:
pass
pass

_dbg = verbosity(0,name='tdlopt');
_dprint = _dbg.dprint;
Expand Down Expand Up @@ -384,6 +385,7 @@ def set_doc (self,doc):
self.doc = doc;
if self._twitem:
if self.doc:
from Timba.GUI.pixmaps import pixmaps
icon = pixmaps.info_blue_round.icon();
# add body tags to convert documentation to rich text
doc = "<body>"+self.doc+"</body>";
Expand Down Expand Up @@ -441,6 +443,7 @@ def __init__ (self,func,name=None,namespace=None,doc=None,job_id=None):
def make_treewidget_item0 (self,parent,after,executor=None):
item = QTreeWidgetItem(parent,after);
item.setText(0,self.name);
from Timba.GUI.pixmaps import pixmaps
item.setIcon(0,pixmaps.gear.icon());
font = item.font(0);
font.setBold(True);
Expand All @@ -455,6 +458,7 @@ def make_treewidget_item (self,parent,after,executor=None):
tw = item.treeWidget();
button = QToolButton(tw);
button.setText(self.name);
from Timba.GUI.pixmaps import pixmaps
button.setIcon(pixmaps.gear.icon());
button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon);
if self.doc:
Expand Down

0 comments on commit 29f7821

Please sign in to comment.