ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/DataDiscovery.py
(Generate patch)

Comparing COMP/CRAB/python/DataDiscovery.py (file contents):
Revision 1.3 by afanfani, Sun Jan 29 01:46:08 2006 UTC vs.
Revision 1.4 by afanfani, Sun Mar 12 01:00:47 2006 UTC

# Line 42 | Line 42 | class DataDiscovery:
42      def __init__(self, owner, dataset, dataTiers, cfg_params):
43  
44   #       Attributes
45 <        self.dbsdataset='/'+dataset+'/datatier/'+owner
45 >        self.owner = owner
46 >        self.dataset = dataset
47          self.dataTiers = dataTiers
48          self.cfg_params = cfg_params
49  
# Line 56 | Line 57 | class DataDiscovery:
57          """
58          Contact DBS
59          """
59        parents = []
60        parentsblocksinfo = {}
60  
61          ## add the PU among the required data tiers if the Digi are requested
62          if (self.dataTiers.count('Digi')>0) & (self.dataTiers.count('PU')<=0) :
63            self.dataTiers.append('PU')
64  
65          ## get info about the requested dataset
66 <        dbs=DBSInfo(self.dbsdataset,self.dataTiers)
66 >        dbs=DBSInfo()
67 >        self.datasets = dbs.getMatchingDatasets(self.owner, self.dataset)
68 >        if len(self.datasets) == 0:
69 >          raise DataDiscoveryError("Owner=%s, Dataset=%s unknown to DBS" % (self.owner, self.dataset))
70 >        if len(self.datasets) > 1:
71 >          raise DataDiscoveryError("Owner=%s, Dataset=%s is ambiguous" % (self.owner, self.dataset))
72          try:
73 <          self.blocksinfo=dbs.getDatasetContents()
73 >          self.dbsdataset = self.datasets[0].getDatasetPath()
74 >          self.blocksinfo = dbs.getDatasetContents(self.dbsdataset)
75 >          self.allblocks.append (self.blocksinfo.keys ()) # add also the current fileblocksinfo
76 >          self.dbspaths.append(self.dbsdataset)
77          except DBSError, ex:
78            raise DataDiscoveryError(ex.getErrorMessage())
79          
80          if len(self.blocksinfo)<=0:
81 <         msg="\nERROR Data %s do not exist in DBS! \n Check the dataset/owner variables in crab.cfg !"%self.dbsdataset
81 >         msg="\nERROR Data for %s do not exist in DBS! \n Check the dataset/owner variables in crab.cfg !"%self.dbsdataset
82           raise NotExistingDatasetError(msg)
83  
77        currentdatatier=string.split(self.blocksinfo.keys()[0],'/')[2]
78        fakedatatier=string.split(self.dbsdataset,'/')[2]
79        currentdbsdataset=string.replace(self.dbsdataset, fakedatatier, currentdatatier)  
80
81        self.dbspaths.append(currentdbsdataset)    # add the requested dbspath
84  
85          ## get info about the parents
86          try:
87 <          parents=dbs.getDatasetProvenance()
87 >          parents=dbs.getDatasetProvenance(self.dbsdataset, self.dataTiers)
88          except DBSInvalidDataTierError, ex:
89            msg=ex.getErrorMessage()+' \n Check the data_tier variable in crab.cfg !\n'
90            raise DataDiscoveryError(msg)
# Line 90 | Line 92 | class DataDiscovery:
92            raise DataDiscoveryError(ex.getErrorMessage())
93  
94          ## check that the user asks for parent Data Tier really existing in the DBS provenance
95 <        self.checkParentDataTier(parents, self.dataTiers, currentdbsdataset)
95 >        self.checkParentDataTier(parents, self.dataTiers)
96  
97          ## for each parent get the corresponding fileblocks
98 <        for aparent in parents:
99 <           ## fill a list of dbspaths
100 <           parentdbsdataset=aparent.getDatasetPath()
101 <           self.dbspaths.append(parentdbsdataset)
102 <           pdbs=DBSInfo(parentdbsdataset,[])
103 <           try:
104 <             parentsblocksinfo=pdbs.getDatasetContents()
105 <           except DBSError, ex:
98 >        try:
99 >          for p in parents:
100 >            ## fill a list of dbspaths
101 >            parentPath = p.getDatasetPath()
102 >            self.dbspaths.append (parentPath)
103 >            parentBlocks = dbs.getDatasetContents (parentPath)
104 >            self.allblocks.append (parentBlocks.keys ())  # add parent fileblocksinfo
105 >        except DBSError, ex:
106              raise DataDiscoveryError(ex.getErrorMessage())
107  
106           self.allblocks.append(parentsblocksinfo.keys()) # add parent fileblocksinfo
107
108        ## all the required blocks
109        self.allblocks.append(self.blocksinfo.keys()) # add also the current fileblocksinfo
110
111
108   # #################################################
109 <    def checkParentDataTier(self, parents, user_datatiers, currentdbsdataset ):
109 >    def checkParentDataTier(self, parents, dataTiers):
110          """
111           check that the data tiers requested by the user really exists in the provenance of the given dataset
112          """
113 <
114 <        current_datatier=string.split(currentdbsdataset,'/')[2]
115 <
116 <        parent_datatypes=[]
117 <        for aparent in parents:
118 <          parent_datatypes.append(aparent.getDataType())
123 <
124 <        for datatier in user_datatiers:
125 <          if parent_datatypes.count(datatier)<=0:
126 <             # the current datatier is not supposed to be in the provenance
127 <             if not (datatier == current_datatier):  
128 <              msg="\nERROR Data %s not published in DBS with asked data tiers : the data tier not found is %s !\n  Check the data_tier variable in crab.cfg !"%(currentdbsdataset,datatier)
129 <              raise  NoDataTierinProvenanceError(msg)
113 >        startType = string.split(self.dbsdataset,'/')[2]
114 >        parentTypes = map(lambda p: p.getDataType(), parents)
115 >        for tier in dataTiers:
116 >          if parentTypes.count(tier) <= 0 and tier != startType:
117 >            msg="\nERROR Data %s not published in DBS with asked data tiers : the data tier not found is %s !\n  Check the data_tier variable in crab.cfg !"%(self.dbsdataset,tier)
118 >            raise  NoDataTierinProvenanceError(msg)
119  
120  
121   # #################################################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines