<commit_before># -*- encoding: utf-8 -*-

from .base import Resource
from pysis.core.sis_datetime import convertToDateTime
from datetime import datetime

__service__ = 'Outputs'

class Outputs(Resource):
        
    def __str__(self):
        return '<Outputs>'
    
    def getFields(self):
        
        if not hasattr(self, 'id'): 
            raise AttributeError(str(self.id), "Service must have id")
        assert isinstance(self.id, int)
                    
        service = self.importService(__service__)  
        return service.getFields(self.id)      
    
    def getData(self, timeStart=None, timeEnd=None, window=None, field=""):
        
        if not hasattr(self, 'id'): 
            raise AttributeError(str(self.id), "Service must have id")
        assert isinstance(self.id, int)
        assert isinstance(field, str)
        
        timeStart = convertToDateTime(timeStart)
        timeEnd = convertToDateTime(timeEnd)
        
        #Validate time parameters
        validTimeParams = [
                           (None, None, None), #no time params
                           (datetime, datetime, int), #all time params
                           (datetime, None, int), #timeStart and window
                           (None, None, int) #window only
                           ] 
        timeElements = (type(timeStart), type(timeEnd), type(window))
        
        isTimeParamsValid = timeElements in validTimeParams        
        if not isTimeParamsValid:
            raise ValueError("Invalid combination of time parameters.")            
        <commit_msg>Fixed bug with output data parameter checking<commit_after># -*- encoding: utf-8 -*-

from .base import Resource
from pysis.core.sis_datetime import convertToDateTime
from datetime import datetime

__service__ = 'Outputs'

class Outputs(Resource):
        
    def __str__(self):
        return '<Outputs>'
    
    def getFields(self):
        
        if not hasattr(self, 'id'): 
            raise AttributeError(str(self.id), "Service must have id")
        assert isinstance(self.id, int)
                    
        service = self.importService(__service__)  
        return service.getFields(self.id)      
    
    def getData(self, timeStart=None, timeEnd=None, window=None, field=""):
        
        if not hasattr(self, 'id'): 
            raise AttributeError(str(self.id), "Service must have id")
        assert isinstance(self.id, int)
        assert isinstance(field, str)
        
        timeStart = convertToDateTime(timeStart)
        timeEnd = convertToDateTime(timeEnd)
        
        #Validate time parameters
        validTimeParams = [
                           (type(None), type(None), type(None)), #no time params
                           (datetime, datetime, int), #all time params
                           (datetime, type(None), int), #timeStart and window
                           (type(None), type(None), int) #window only
                           ] 
        timeElements = (type(timeStart), type(timeEnd), type(window))
        
        isTimeParamsValid = timeElements in validTimeParams        
        if not isTimeParamsValid:
            raise ValueError("Invalid combination of time parameters.")            
        
{'fraction_non_alphanumeric': 0.09057527539779682, 'fraction_numerical': 0.0006119951040391676, 'mean_word_length': 1.8550218340611353, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4595414', 'n_tokens_mistral': 819, 'n_tokens_neox': 814, 'n_words': 230}