in utils/lookout_equipment_utils.py [0:0]
def create(self):
"""
Creates a Lookout for Equipment dataset
RETURNS
=======
create_dataset_response: string
Response of the create dataset API
"""
# Initialization:
has_more_records = True
# pp = pprint.PrettyPrinter(depth=4)
# Checks if the dataset already exists:
list_datasets_response = self.client.list_datasets(
DatasetNameBeginsWith=self.dataset_name
)
dataset_exists = False
for dataset_summary in list_datasets_response['DatasetSummaries']:
if dataset_summary['DatasetName'] == self.dataset_name:
dataset_exists = True
break
# If the dataset exists we just returns that message:
if dataset_exists:
print((f'Dataset "{self.dataset_name}" already exists and can be '
'used to ingest data or train a model.'))
# Otherwise, we create it:
else:
print(f'Dataset "{self.dataset_name}" does not exist, creating it...\n')
try:
create_dataset_response = self.client.create_dataset(
DatasetName=self.dataset_name,
DatasetSchema={
'InlineDataSchema': self.dataset_schema
},
ClientToken=uuid.uuid4().hex
)
return create_dataset_response
except Exception as e:
print(e)