def _checkPrimaryDataset(self, kwargs): """ Validate the primary dataset name using the WMCore.Lexicon method primdataset(), which does the same validation as DBS (see discussion with Yuyi Guo in following github CRABClient issue: https://github.com/dmwm/CRABClient/issues/4257). """ ## This if statement should actually never evaluate to True, because ## the client always defines kwargs['inputdata']. if 'inputdata' not in kwargs: msg = "Server parameter 'inputdata' is not defined." msg += " Unable to validate the primary dataset name." raise InvalidParameter(msg) try: ## The client defines kwargs['inputdata'] = "/<primary-dataset-name>", ## i.e. it adds a "/" at the beginning, which we should remove if we ## want to do the validation of the primary dataset name only. ## (The client puts the primary dataset name in kwargs['inputdata'], ## because the PostJob extracts the primary dataset name from this ## parameter splitting by "/" and taking the element 1, which is the ## right thing to do when kwargs['inputdata'] is the input dataset in ## an analysis job type.) primdataset(kwargs['inputdata'][1:]) except AssertionError: ## This message is more descriptive than if we would use the message ## from AssertionError exception, but I had to explicitely write the ## regular expression [a-zA-Z][a-zA-Z0-9\-_]*, which is not nice. ## The message from AssertionError exception would be: ## "'<kwargs['inputdata'][1:]>' does not match regular expression [a-zA-Z0-9\.\-_]+". msg = "Invalid CRAB configuration parameter Data.primaryDataset." msg += " The parameter should not have more than 99 characters" msg += " and should match the regular expression [a-zA-Z][a-zA-Z0-9\-_]*" raise InvalidParameter(msg)
def _checkPrimaryDataset(self, kwargs, optional=False): """ Validate the primary dataset name using the WMCore.Lexicon method primdataset(), which does the same validation as DBS (see discussion with Yuyi Guo in following github CRABClient issue: https://github.com/dmwm/CRABClient/issues/4257). """ if 'primarydataset' not in kwargs: if optional: return else: msg = "Missing 'primarydataset' parameter." raise InvalidParameter(msg) try: primdataset(kwargs['primarydataset']) except AssertionError: ## This message is more descriptive than if we would use the message ## from AssertionError exception, but I had to explicitely write the ## regular expression [a-zA-Z][a-zA-Z0-9\-_]*, which is not nice. ## The message from AssertionError exception would be: ## "'<kwargs['primarydataset']>' does not match regular expression [a-zA-Z0-9\.\-_]+". msg = "Invalid 'primarydataset' parameter." msg += " The parameter should not have more than 99 characters" msg += " and should match the regular expression [a-zA-Z][a-zA-Z0-9\-_]*" raise InvalidParameter(msg)
def _checkPrimaryDataset(kwargs, optional=False): """ Validate the primary dataset name using the WMCore.Lexicon method primdataset(), which does the same validation as DBS (see discussion with Yuyi Guo in following github CRABClient issue: https://github.com/dmwm/CRABClient/issues/4257). """ if 'primarydataset' not in kwargs: if optional: return else: msg = "Missing 'primarydataset' parameter." raise InvalidParameter(msg) try: primdataset(kwargs['primarydataset']) except AssertionError: ## This message is more descriptive than if we would use the message ## from AssertionError exception, but I had to explicitely write the ## regular expression [a-zA-Z][a-zA-Z0-9\-_]*, which is not nice. ## The message from AssertionError exception would be: ## "'<kwargs['primarydataset']>' does not match regular expression [a-zA-Z0-9\.\-_]+". msg = "Invalid 'primarydataset' parameter." msg += " The parameter should not have more than 99 characters" msg += " and should match the regular expression [a-zA-Z][a-zA-Z0-9\-_]*" raise InvalidParameter(msg)