<commit_before># Copyright 2014 Diamond Light Source Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
.. module:: plugin_runner
   :platform: Unix
   :synopsis: Class to control the plugin and interact with the transport
   layer.  It inherits dynamically from chosen transport type at run time

.. moduleauthor:: <NAME> <<EMAIL>>

"""
import os
import logging 
import time
import sys

from mpi4py import MPI
import copy

from savu.data.experiment_collection import Experiment
from savu.plugins.base_loader import BaseLoader
from savu.plugins.base_saver import BaseSaver

class PluginRunner(object):
    """
    The PluginRunner class controls the plugins and performs the interaction 
    between the plugin and transport layers.  It inherits from the chosen 
    transport mechanism. 
    """
    
    def __init__(self, options):
        print("CAlling the Init method")
        class_name = "savu.core.transports." + options["transport"] + "_transport"
        self.add_base(self.import_class(class_name))
        self.transport_control_setup(options)
        self.run_plugin_list(options)
        
        
    def import_class(self, class_name):
        name = class_name
        mod = __import__(name)
        components = name.split('.')
        for comp in components[1:]:
            mod = getattr(mod, comp)
        temp = name.split('.')[-1]
        module2class = ''.join(x.capitalize() for x in temp.split('_'))
        return getattr(mod, module2class.split('.')[-1])
            
            
    def add_base(self, ExtraBase):
        cls = self.__class__
        self.__class__ = cls.__class__(cls.__name__, (cls, ExtraBase), {})

    def run_plugin_list(self, options):
        experiment = Experiment(options)
        #plugin_list = experiment.info["plugin_list"]
        plugin_list = experiment.meta_data.plugin_list.plugin_list

        #*** temporary fix!!!
        plugins = []
        temp = {}
        temp['name'] = "nxtomo_loader"
        temp['id'] = 'savu.plugins.nxtomo_loader'
        temp['data'] = {}
        temp['loader_params'] = {'calibration_path': '/home/clb02321/DAWN_stable/Savu/test_data/LaB6_calibration_output.nxs'}
        plugins.append(temp)
#        plugins.append(experiment.info["plugin_list"][0])
##        temp = {}
##        temp['name'] = "median_filter"
##        temp['id'] = 'savu.plugins.median_filter'
##        temp['data'] = {}
##        plugins.append(temp)
        temp = {}
        temp['name'] = "astra_FBP_recon"
        temp['id'] = 'savu.plugins.astra_recon_cpu'
        temp['data'] = {}
        temp['in_dataset'] = ["tomo"] # a list of data_sets
        temp['out_dataset'] = ["tomo"]
        plugins.append(temp)
        #plugins.append(experiment.info["plugin_list"][1])
        temp = {}
        temp['name'] = "hdf5_tomo_saver"
        temp['id'] = 'savu.plugins.hdf5_tomo_saver'
        temp['data'] = {}
        plugins.append(temp)
        experiment.meta_data.set_meta_data("plugin_list", plugins)
        plugin_list = experiment.meta_data.get_meta_data("plugin_list")        
        #***        

        self.run_plugin_list_check(experiment, plugin_list)
<commit_msg>Minor changes<commit_after># Copyright 2014 Diamond Light Source Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
.. module:: plugin_runner
   :platform: Unix
   :synopsis: Class to control the plugin and interact with the transport
   layer.  It inherits dynamically from chosen transport type at run time

.. moduleauthor:: <NAME> <<EMAIL>>

"""
import os
import logging 
import time
import sys

from mpi4py import MPI
import copy

from savu.data.experiment_collection import Experiment
from savu.plugins.base_loader import BaseLoader
from savu.plugins.base_saver import BaseSaver

class PluginRunner(object):
    """
    The PluginRunner class controls the plugins and performs the interaction 
    between the plugin and transport layers.  It inherits from the chosen 
    transport mechanism. 
    """
    
    def __init__(self, options):
        print("CAlling the Init method")
        class_name = "savu.core.transports." + options["transport"] + "_transport"
        self.add_base(self.import_class(class_name))
        self.transport_control_setup(options)
        self.run_plugin_list(options)
        
        
    def import_class(self, class_name):
        name = class_name
        mod = __import__(name)
        components = name.split('.')
        for comp in components[1:]:
            mod = getattr(mod, comp)
        temp = name.split('.')[-1]
        module2class = ''.join(x.capitalize() for x in temp.split('_'))
        return getattr(mod, module2class.split('.')[-1])
            
            
    def add_base(self, ExtraBase):
        cls = self.__class__
        self.__class__ = cls.__class__(cls.__name__, (cls, ExtraBase), {})

    def run_plugin_list(self, options):
        experiment = Experiment(options)
        #plugin_list = experiment.info["plugin_list"]
        plugin_list = experiment.meta_data.plugin_list.plugin_list

        #*** temporary fix!!!
        plugins = []
        temp = {}
        temp['name'] = "nxfluo_loader"
        temp['id'] = 'savu.plugins.nxfluo_loader'
        temp['data'] = {}
#        temp['loader_params'] = {'calibration_path': '/home/clb02321/DAWN_stable/Savu/test_data/LaB6_calibration_output.nxs'}
        plugins.append(temp)
#        plugins.append(experiment.info["plugin_list"][0])
##        temp = {}
##        temp['name'] = "median_filter"
##        temp['id'] = 'savu.plugins.median_filter'
##        temp['data'] = {}
##        plugins.append(temp)
        temp = {}
        temp['name'] = "astra_FBP_recon"
        temp['id'] = 'savu.plugins.astra_recon_cpu'
        temp['data'] = {}
        temp['in_dataset'] = ["tomo"] # a list of data_sets
        temp['out_dataset'] = ["tomo"]
        plugins.append(temp)
        #plugins.append(experiment.info["plugin_list"][1])
        temp = {}
        temp['name'] = "hdf5_tomo_saver"
        temp['id'] = 'savu.plugins.hdf5_tomo_saver'
        temp['data'] = {}
        plugins.append(temp)
        experiment.meta_data.set_meta_data("plugin_list", plugins)
        plugin_list = experiment.meta_data.get_meta_data("plugin_list")        
        #***        

        self.run_plugin_list_check(experiment, plugin_list)

{'fraction_non_alphanumeric': 0.11788007102854801, 'fraction_numerical': 0.006556481355006146, 'mean_word_length': 2.8699788583509513, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2943582', 'n_tokens_mistral': 2186, 'n_tokens_neox': 2139, 'n_words': 549}