本文整理汇总了Python中bamboo.models.observation.Observation.delete_all方法的典型用法代码示例。如果您正苦于以下问题:Python Observation.delete_all方法的具体用法?Python Observation.delete_all怎么用?Python Observation.delete_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bamboo.models.observation.Observation
的用法示例。
在下文中一共展示了Observation.delete_all方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete
# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import delete_all [as 别名]
def test_delete(self):
self._save_observations()
records = Observation.find(self.dataset)
self.assertNotEqual(records, [])
Observation.delete_all(self.dataset)
records = [x for x in Observation.find(self.dataset)]
self.assertEqual(records, [])
示例2: remove_parent_observations
# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import delete_all [as 别名]
def remove_parent_observations(self, parent_id):
"""Remove obervations for this dataset with the passed `parent_id`.
:param parent_id: Remove observations with this ID as their parent
dataset ID.
"""
Observation.delete_all(self, {PARENT_DATASET_ID: parent_id})
示例3: delete_task
# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import delete_all [as 别名]
def delete_task(dataset, query=None):
"""Background task to delete dataset and its associated observations."""
Observation.delete_all(dataset, query=query)
if query is None:
super(dataset.__class__, dataset).delete(
{DATASET_ID: dataset.dataset_id})
Observation.delete_encoding(dataset)
示例4: test_delete_all
# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import delete_all [as 别名]
def test_delete_all(self):
self.__save_records()
records = Observation.find(self.dataset)
self.assertNotEqual(records, [])
Observation.delete_all(self.dataset)
records = Observation.find(self.dataset)
self.assertEqual(records, [])
示例5: replace_observations
# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import delete_all [as 别名]
def replace_observations(self, dframe, overwrite=False,
set_num_columns=True):
"""Remove all rows for this dataset and save the rows in `dframe`.
:param dframe: Replace rows in this dataset with this DataFrame's rows.
:returns: BambooFrame equivalent to the passed in `dframe`.
"""
self.build_schema(dframe, overwrite=overwrite,
set_num_columns=set_num_columns)
dframe = self.add_id_column_to_dframe(dframe)
Observation.delete_all(self)
return self.save_observations(dframe)
示例6: replace_observations
# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import delete_all [as 别名]
def replace_observations(self, dframe, overwrite=False,
set_num_columns=True):
"""Remove all rows for this dataset and save the rows in `dframe`.
:param dframe: Replace rows in this dataset with this DataFrame's rows.
:param overwrite: If true replace the schema, otherwise update it.
Default False.
:param set_num_columns: If true update the dataset stored number of
columns. Default True.
:returns: DataFrame equivalent to the passed in `dframe`.
"""
self.build_schema(dframe, overwrite=overwrite,
set_num_columns=set_num_columns)
Observation.delete_all(self)
return self.save_observations(dframe)
示例7: __create_or_update
# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import delete_all [as 别名]
def __create_or_update(self, url=None, csv_file=None, json_file=None,
schema=None, na_values=[], perish=0,
dataset_id=None):
result = None
error = 'url, csv_file or schema required'
try:
if schema or url or csv_file or json_file:
if dataset_id is None:
dataset = Dataset()
dataset.save()
else:
dataset = Dataset.find_one(dataset_id)
Observation.delete_all(dataset)
if schema:
dataset.import_schema(schema)
na_values = safe_json_loads(na_values)
if url:
dataset.import_from_url(url, na_values=na_values)
elif csv_file:
dataset.import_from_csv(csv_file, na_values=na_values)
elif json_file:
dataset.import_from_json(json_file)
result = {Dataset.ID: dataset.dataset_id}
perish = parse_int(perish)
perish and dataset.delete(countdown=perish)
except urllib2.URLError:
error = 'could not load: %s' % url
except IOError:
error = 'could not get a filehandle for: %s' % csv_file
except JSONError as e:
error = e.__str__()
self.set_response_params(result, success_status_code=201)
return self._dump_or_error(result, error)
示例8: delete_task
# 需要导入模块: from bamboo.models.observation import Observation [as 别名]
# 或者: from bamboo.models.observation.Observation import delete_all [as 别名]
def delete_task(dataset):
"""Background task to delete dataset and its associated observations."""
Observation.delete_all(dataset)
super(dataset.__class__, dataset).delete({DATASET_ID: dataset.dataset_id})