<commit_before>"""

Authors: <NAME>

Copyright 2015 CSIRO, Australian Government Bureau of Meteorology

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 containing a VT module that is very open.

DataSet of some kind and a Pipeline-style pattern.

"""

from vistrails.core.modules import vistrails_module
from vistrails.core.modules.basic_modules import String, List

from cwsl.configuration import configuration
from cwsl.core.process_unit import ProcessUnit
from cwsl.core.file_creator import FileCreator
from cwsl.core.constraint import Constraint


class SDMDataExtract(vistrails_module.Module):
    '''
    This module gives users freedom to run what ever command they want
    on some data.
    '''

    # Define the module ports.
    _input_ports = [('cod_dataset', 'csiro.au.cwsl:VtDataSet')]

    _output_ports = [('out_dataset', 'csiro.au.cwsl:VtDataSet')]

    def __init__(self):

        super(SDMDataExtract, self).__init__()
        
        self.required_modules = ['python']

    def compute(self):

        in_dataset = self.getInputFromPort('cod_dataset')

        output_pattern = "This/Is/The/Output/Pattern."
        
        this_process = ProcessUnit([in_dataset],
                                   output_pattern,
                                   command,
                                   in_dataset.constraints)

        this_process.execute(simulate=configuration.simulate_execution)
        process_output = this_process.file_creator

        self.setResult('out_dataset', process_output)
        
        # Unload the modules at the end.
        self.module_loader.unload(self.required_modules)<commit_msg>Switched to the correct module loading method<commit_after>"""

Authors: <NAME>

Copyright 2015 CSIRO, Australian Government Bureau of Meteorology

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 containing a VT module that is very open.

DataSet of some kind and a Pipeline-style pattern.

"""

from vistrails.core.modules import vistrails_module
from vistrails.core.modules.basic_modules import String, List

from cwsl.configuration import configuration
from cwsl.core.process_unit import ProcessUnit
from cwsl.core.file_creator import FileCreator
from cwsl.core.constraint import Constraint


class SDMDataExtract(vistrails_module.Module):
    ''' This module extracts the relevant SDM data

    from an observational it does this by re-ordering
    daily data from a specially formatted AWAP dataset.

    '''

    # Define the module ports.
    _input_ports = [('cod_dataset', 'csiro.au.cwsl:VtDataSet')]

    _output_ports = [('out_dataset', 'csiro.au.cwsl:VtDataSet')]

    def __init__(self):

        super(SDMDataExtract, self).__init__()
        
        self._required_modules = {'required_modules': ['python']}

    def compute(self):

        in_dataset = self.getInputFromPort('cod_dataset')

        print([thing for thing in in_dataset.files])

        command = "echo This is the command to run."
        
        # The data is written out to the default
        # location.
        output_pattern = FileCreator.default_pattern(in_dataset.constraints, temp=True)
        this_process = ProcessUnit([in_dataset],
                                   output_pattern,
                                   command,
                                   in_dataset.constraints,
                                   execution_options=self._required_modules)

        this_process.execute(simulate=configuration.simulate_execution)
        process_output = this_process.file_creator

        self.setResult('out_dataset', process_output)
{'fraction_non_alphanumeric': 0.070326278659612, 'fraction_numerical': 0.003527336860670194, 'mean_word_length': 3.0800359712230216, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7366224', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1188, 'n_words': 405}