本文整理汇总了Python中snakebite.client.Client.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Client.delete方法的具体用法?Python Client.delete怎么用?Python Client.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snakebite.client.Client
的用法示例。
在下文中一共展示了Client.delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_item
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import delete [as 别名]
def delete_item(config, filepath='', localpath=''):
if(config['BACKEND'] == 'hdfs'):
client = Client(socket.gethostname(), config['HADOOP_RPC_PORT'], use_trash=False)
del_gen = client.delete([filepath], recurse=True)
for del_item in del_gen:
pass
elif(config['BACKEND'] == 'swift'):
pass # To be implemented
# Deleting modules or datasets from local directories (will also suffice for nfs backend)
if(os.path.isdir(localpath)): # Check if it is a dataset
shutil.rmtree(localpath)
else:
try:
os.remove(localpath)
except OSError:
pass
示例2: crfalign
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import delete [as 别名]
def crfalign(sc, inputFilename, outputDirectory,
limit=LIMIT, location='hdfs', outputFormat="text", partitions=None, deleteFirst=True):
# crfConfigDir = os.path.join(os.path.dirname(__file__), "data/config")
# def cpath(n):
# return os.path.join(crfConfigDir, n)
# smEyeColor = HybridJaccard(ref_path=cpath("eyeColor_reference_wiki.txt"),
# config_path=cpath("eyeColor_config.txt"))
# smHairColor = HybridJaccard(ref_path=cpath("hairColor_reference_wiki.txt"),
# config_path=cpath("hairColor_config.txt"))
# print smEyeColor, smHairColor
if location == "hdfs":
if deleteFirst:
namenode = "memex-nn1"
port = 8020
client = Client(namenode, 8020, use_trash=True)
try:
for deleted in client.delete([outputDirectory], recurse=True):
print deleted
except FileNotFoundException as e:
pass
# hypothesis1: data fetched this way prompts the lzo compression error
# hypothesis2: but it doesn't matter, error is just a warning
rdd_crfl = sc.textFile(inputFilename)
rdd_crfl.setName('rdd_crfl')
if limit:
rdd_crfl = sc.parallelize(rdd_crfl.take(limit))
if partitions:
rdd_crfl = rdd_crfl.repartition(partitions)
rdd_final = rdd_crfl
print outputFormat
if outputFormat == "sequence":
rdd_final.saveAsSequenceFile(outputDirectory)
elif outputFormat == "text":
print "saving to %s" % outputDirectory
rdd_final.saveAsTextFile(outputDirectory)
else:
raise RuntimeError("Unrecognized output format: %s" % outputFormat)
示例3: Client
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import delete [as 别名]
from snakebite.client import Client
from constants import *
client = Client('localhost', NAMENODE_PORT)
for p in client.delete(['/foo/bar','/input'], recurse=True):
print p
示例4: remove
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import delete [as 别名]
def remove(self):
client = Client(self._host, self._port, effective_user=self._user, use_trash=False)
it = client.delete([self._partial], recurse=True)
for elmt in it:
pass
示例5: crfalign
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import delete [as 别名]
def crfalign(sc, inputFilename, outputDirectory,
limit=LIMIT, location='hdfs', outputFormat="text", partitions=None, deleteFirst=True):
crfConfigDir = os.path.join(os.path.dirname(__file__), "data/config")
def cpath(n):
return os.path.join(crfConfigDir, n)
smEyeColor = HybridJaccard(ref_path=cpath("eyeColor_reference_wiki.txt"),
config_path=cpath("eyeColor_config.txt"))
smHairColor = HybridJaccard(ref_path=cpath("hairColor_reference_wiki.txt"),
config_path=cpath("hairColor_config.txt"))
print smEyeColor, smHairColor
if location == "hdfs":
if deleteFirst:
namenode = "memex-nn1"
port = 8020
client = Client(namenode, 8020, use_trash=True)
try:
for deleted in client.delete([outputDirectory], recurse=True):
print deleted
except FileNotFoundException as e:
pass
# hypothesis1: data fetched this way prompts the lzo compression error
# hypothesis2: but it doesn't matter, error is just a warning
if partitions:
if limit:
rdd_crfl = sc.parallelize(rdd_crfl.take(limit))
rdd_crfl = rdd_crfl.repartition(partitions)
else:
print inputFilename
rdd_crfl = sc.textFile(inputFilename, minPartitions=partitions)
else:
rdd_crfl = sc.textFile(inputFilename)
rdd_crfl.setName('rdd_crfl')
# rdd_crfl.persist()
print "beginning: %s partitions" % rdd_crfl.getNumPartitions()
# "value-only" RDD, not a pair RDD
# but we have the URI in the -3 position
# and the index in the -2 position
rdd_withuri = rdd_crfl.map(lambda x: reconstructTuple(x))
# Note: groupByKey returns iterable, not data; so no point in printing
rdd_grouped = rdd_withuri.groupByKey()
# sort the vectors by index (within key groups)
rdd_sorted = rdd_grouped.mapValues(lambda x: [l[1:] for l in sorted(x, key=lambda r: int(r[0]))])
# find all contiguous spans of marked-up tokens
# returns 0 or more dicts per URI key
rdd_spans = rdd_sorted.mapValues(lambda x: computeSpans(x, indexed=True))
# flatten to (URI, single dict) on each line
rdd_flat = rdd_spans.flatMapValues(lambda x: list(x))
# rdd_flat = rdd_flat.coalesce(rdd_flat.getNumPartitions() / 3)
# # map any eyeColor spans using smEyeColor, hairType spans using smHairColor
# rdd_aligned = rdd_flat.mapValues(lambda x: alignToControlledVocab(x, {"eyeColor": smEyeColor, "hairType": smHairColor}))
rdd_aligned = rdd_flat.mapValues(lambda x: alignToControlledVocab(x, {"eyeColor": smEyeColor.findBestMatch, "hairType": smHairColor.findBestMatch}))
# rdd_aligned = rdd_flat.mapValues(lambda x: alignToControlledVocab(x, {"eyeColor": fakeFindBestMatch, "hairType": fakeFindBestMatch}))
# rdd_aligned = rdd_flat.mapValues(lambda x: alignToControlledVocab(x, {}))
# rdd_aligned = rdd_spans
# rdd_final = rdd_crfl
rdd_final = rdd_aligned
print outputFormat
if outputFormat == "sequence":
rdd_final.saveAsSequenceFile(outputDirectory)
elif outputFormat == "text":
print "saving to %s" % outputDirectory
rdd_final.saveAsTextFile(outputDirectory)
else:
raise RuntimeError("Unrecognized output format: %s" % outputFormat)
示例6: timedelta
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import delete [as 别名]
swift_client = swift.Connection(
user = swift_user,
key = swift_key,
authurl = swift_authurl)
# read list of files
src_files = []
if run_mode == "hdfs":
# spotify's snakebite as hdfs client
src_files = [ hdfs_url + files['path'] for files in hdfs_client.ls([source_files]) ]
# deleting output directory if exists
if (hdfs_client.test(target_dir, exists = True, directory = True)):
hdfs_client.delete(target_dir)
hdfs_client.rmdir(target_dir)
elif run_mode == "swift":
# read list of files from swift src_files = []
source_files = '|'.join([ '(pagecounts-' + (datetime.now() - timedelta(hours=i)).strftime("%Y%m%d-%H") + '(.*))' for i in range(48, 71) ])
src_file_regex = re.compile(source_files)
for data in swift_client.get_container(source_dir)[1]:
if src_file_regex.match(data['name']):
src_files.append(data['name'])
src_files.sort(key = lambda x: os.path.basename(x))
else:
# read list of files from local
src_files = filter(os.path.isfile, glob.glob(os.path.join(source_dir, source_files)))