source: TI03-DataExtractor/branches/old_stuff/latest_dx/dx/pydxs/RequestCost.py @ 793

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI03-DataExtractor/branches/old_stuff/latest_dx/dx/pydxs/RequestCost.py@793
Revision 793, 2.0 KB checked in by astephen, 13 years ago (diff)

Put all the old code in the old_stuff branch.

Line 
1#   Copyright (C) 2004 CCLRC & NERC( Natural Environment Research Council ).
2#   This software may be distributed under the terms of the
3#   Q Public License, version 1.0 or later. http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt
4
5"""
6RequestCost.py
7==============
8
9Contains the class RequestCost that is used to estimate the cost (in
10data volume and processing time) of a user request.
11
12""" 
13
14# Import library modules
15import os, sys
16
17# Import package modules
18from serverConfig import *
19from common import *
20from localRules import *
21from MetadataExtractor import MetadataExtractor
22
23class RequestCost(MetadataExtractor):
24    """
25    Class used to estimate the cost of a request in terms of the data
26    volume produced and the processing time to produce the request.
27    There is also a localCostingRules method included for you to add your
28    own algorithms that relate to local rules or specific datasets.
29    """
30           
31    def localCostingRules(self, estimatedDuration):
32        """
33        Method to be defined by local extractor administrator. Essentially a
34        hook for your local rules and algorithms. It takes in the estimated
35        duration and allows you to alter it as you see fit.
36        """
37        scale_factor=1
38        return scale_factor*estimatedDuration
39
40
41    def getVolumeEstimate(self, format="NetCDF"):
42        """
43        Method to get that the volume of data requested.
44        """
45        size=self.getRequestSizeInBytes()
46        if format=="NASA Ames": # NA is about 5 x NC in volume
47            size=size*5
48        return size
49                               
50                       
51    def getDurationEstimate(self, format="NetCDF"):
52        """
53        Method to estimate the time it will take to process a request.
54        """
55        size=self.getRequestSizeInBytes()       
56        duration=size*TIMING_SCALE_FACTOR
57        dur=self.localCostingRules(duration)
58        if format=="NASA Ames":
59            dur=dur*1.5
60        return dur     
61       
62       
63    def getDurationAndVolume(self, format="NetCDF"):
64        """
65        Returns the estimated duration and volume of the request.
66        """
67        estDur=self.getDurationEstimate(format)
68        estVol=self.getVolumeEstimate(format)
69        return (estDur, estVol)
70       
71if __name__=="__main__":
72
73    pass
Note: See TracBrowser for help on using the repository browser.