diff --git a/mapclientplugins/argonsceneexporterstep/step.py b/mapclientplugins/argonsceneexporterstep/step.py index 94716f4..f3b7f5b 100644 --- a/mapclientplugins/argonsceneexporterstep/step.py +++ b/mapclientplugins/argonsceneexporterstep/step.py @@ -5,6 +5,7 @@ import json from PySide6 import QtGui, QtWidgets, QtCore +from cmlibs.argon.argondocument import ArgonDocument from mapclient.mountpoints.workflowstep import WorkflowStepMountPoint from mapclientplugins.argonsceneexporterstep.configuredialog import ConfigureDialog @@ -32,9 +33,13 @@ def __init__(self, location): # Add any other initialisation code here: self._icon = QtGui.QImage(':/argonsceneexporterstep/images/data-sink.png') # Ports: - self.addPort(('http://physiomeproject.org/workflow/1.0/rdf-schema#port', + self.addPort([('http://physiomeproject.org/workflow/1.0/rdf-schema#port', 'http://physiomeproject.org/workflow/1.0/rdf-schema#uses', - 'https://cmlibs.org/1.0/rdf-schema#ArgonDocument')) + 'https://cmlibs.org/1.0/rdf-schema#ArgonDocument'), + ('http://physiomeproject.org/workflow/1.0/rdf-schema#port', + 'http://physiomeproject.org/workflow/1.0/rdf-schema#uses', + 'http://physiomeproject.org/workflow/1.0/rdf-schema#file_location') + ]) self.addPort(('http://physiomeproject.org/workflow/1.0/rdf-schema#port', 'http://physiomeproject.org/workflow/1.0/rdf-schema#provides', 'http://physiomeproject.org/workflow/1.0/rdf-schema#directory_location')) @@ -103,16 +108,25 @@ def execute(self): finally: QtWidgets.QApplication.restoreOverrideCursor() - def setPortData(self, index, dataIn): + def setPortData(self, index, data_in): """ Add your code here that will set the appropriate objects for this step. The index is the index of the port in the port list. If there is only one uses port for this step then the index can be ignored. :param index: Index of the port to return. - :param dataIn: The data to set for the port at the given index. + :param data_in: The data to set for the port at the given index. """ - self._document = dataIn # http://physiomeproject.org/workflow/1.0/rdf-schema#file_location + if isinstance(data_in, str) and os.path.isfile(data_in): + with open(data_in) as fh: + content = fh.read() + + document = ArgonDocument() + document.initialiseVisualisationContents() + document.deserialize(content, base_path=os.path.dirname(data_in)) + data_in = document + + self._document = data_in # http://physiomeproject.org/workflow/1.0/rdf-schema#file_location def getPortData(self, index): """ diff --git a/setup.py b/setup.py index 761257a..2b0aa80 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ def readfile(filename, split=False): readme = readfile("README.rst", split=True)[3:] # skip title # For requirements not hosted on PyPi place listings # into the 'requirements.txt' file. -requires = ['PySide6', 'cmlibs.exporter >= 0.6.2'] # minimal requirements listing +requires = ['PySide6', 'cmlibs.exporter >= 0.6.2', 'cmlibs.argon >= 0.5'] # minimal requirements listing source_license = readfile("LICENSE")