本文整理匯總了Python中rucio.client.Client.set_metadata方法的典型用法代碼示例。如果您正苦於以下問題:Python Client.set_metadata方法的具體用法?Python Client.set_metadata怎麽用?Python Client.set_metadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rucio.client.Client
的用法示例。
在下文中一共展示了Client.set_metadata方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setMetaData
# 需要導入模塊: from rucio.client import Client [as 別名]
# 或者: from rucio.client.Client import set_metadata [as 別名]
def setMetaData(self,dsn,metadata=None):
# register dataset
client = RucioClient()
try:
scope,dsn = self.extract_scope(dsn)
for tmpKey,tmpValue in metadata.iteritems():
client.set_metadata(scope,dsn,key=tmpKey,value=tmpValue)
except:
errType,errVale = sys.exc_info()[:2]
return False,'%s %s' % (errType,errVale)
return True,''
示例2: registerDataset
# 需要導入模塊: from rucio.client import Client [as 別名]
# 或者: from rucio.client.Client import set_metadata [as 別名]
def registerDataset(self,dsn,lfns=[],guids=[],sizes=[],checksums=[],lifetime=None,scope=None,metadata=None):
presetScope = scope
files = []
for lfn, guid, size, checksum in zip(lfns, guids, sizes, checksums):
if lfn.find(':') > -1:
s, lfn = lfn.split(':')[0], lfn.split(':')[1]
else:
s = scope
file = {'scope': s, 'name': lfn, 'bytes': size, 'meta': {'guid': guid}}
if checksum.startswith('md5:'):
file['md5'] = checksum[4:]
elif checksum.startswith('ad:'):
file['adler32'] = checksum[3:]
files.append(file)
# register dataset
client = RucioClient()
try:
scope,dsn = self.extract_scope(dsn)
if presetScope is not None:
scope = presetScope
client.add_dataset(scope=scope, name=dsn, meta=metadata)
if lifetime != None:
client.set_metadata(scope,dsn,key='lifetime',value=lifetime*86400)
except DataIdentifierAlreadyExists:
pass
# open dataset just in case
try:
client.set_status(scope,dsn,open=True)
except:
pass
# add files
if len(files) > 0:
iFiles = 0
nFiles = 1000
while iFiles < len(files):
tmpFiles = files[iFiles:iFiles+nFiles]
try:
client.add_files_to_dataset(scope=scope,name=dsn,files=tmpFiles, rse=None)
except FileAlreadyExists:
for f in tmpFiles:
try:
client.add_files_to_dataset(scope=scope, name=dsn, files=[f], rse=None)
except FileAlreadyExists:
pass
iFiles += nFiles
vuid = hashlib.md5(scope+':'+dsn).hexdigest()
vuid = '%s-%s-%s-%s-%s' % (vuid[0:8], vuid[8:12], vuid[12:16], vuid[16:20], vuid[20:32])
duid = vuid
return {'duid': duid, 'version': 1, 'vuid': vuid}
示例3: eraseDataset
# 需要導入模塊: from rucio.client import Client [as 別名]
# 或者: from rucio.client.Client import set_metadata [as 別名]
def eraseDataset(self,dsn,scope=None, grace_period=None):
presetScope = scope
# register dataset
client = RucioClient()
try:
scope,dsn = self.extract_scope(dsn)
if presetScope is not None:
scope = presetScope
if grace_period is not None:
value = grace_period * 60 * 60
else:
value = 0.0001
client.set_metadata(scope=scope, name=dsn, key='lifetime', value=value)
except:
errType,errVale = sys.exc_info()[:2]
return False,'%s %s' % (errType,errVale)
return True,''
示例4: RucioClient
# 需要導入模塊: from rucio.client import Client [as 別名]
# 或者: from rucio.client.Client import set_metadata [as 別名]
import sys
from rucio.client import Client as RucioClient
client = RucioClient()
# scope = sys.argv[1]
# name = sys.argv[2]
# rep.list_replicas([{'scope':'ams-2011B-ISS.B620-pass4', 'name':'1340252898.00981893.root'}])
# for x in rep.list_replicas([{'scope':scope, 'name':name}]):
# print x
from rucio.common.utils import generate_uuid
account = 'chenghsi'
scope = 'ams-user-chenghsi'
name = 'file20150709T105442'
# client.add_replication_rule(dids=[{'scope': 'ams-user-chenghsi', 'name':'file20150709T105442'}],copies=1,rse_expression='EOS01_AMS02SCRATCHDISK',weight=None,
# lifetime=1, grouping='DATASET', account=account, locked=False, notify='N',ignore_availability=True)
import pdb; pdb.set_trace()
# for key, value in client.get_metadata(scope, name).iteritems():
# print key, value
client.set_metadata(scope, name, 'guid', generate_uuid())
示例5: IN
# 需要導入模塊: from rucio.client import Client [as 別名]
# 或者: from rucio.client.Client import set_metadata [as 別名]
files.append(tmpLFN)
print
print 'found {0} lost files -> {1}'.format(len(files), ','.join(files))
s,jediTaskID = taskBuffer.resetFileStatusInJEDI('',True,options.ds,files,[],options.dryRun)
if options.dryRun:
sys.exit(0)
if s:
if options.resurrectDS:
sd,so = taskBuffer.querySQLS('SELECT datasetName FROM ATLAS_PANDA.JEDI_Datasets WHERE jediTaskID=:id AND type IN (:t1,:t2)',
{':id': jediTaskID, ':t1': 'output', ':t2': 'log'})
rc = RucioClient()
for datasetName, in so:
for i in range(3):
try:
scope, name = rucioAPI.extract_scope(datasetName)
rc.get_did(scope, name)
break
except DataIdentifierNotFound:
print 'resurrect {0}'.format(datasetName)
rc.resurrect([{'scope': scope, 'name': name}])
try:
rc.set_metadata(scope, name, 'lifetime', None)
except:
pass
print Client.retryTask(jediTaskID, noChildRetry=options.noChildRetry)[-1][-1]
print 'done for jediTaskID={0}'.format(jediTaskID)
else:
print 'failed'