Skip to content

Commit f0dd5a1

Browse files
committed
Add example dataset to new projects
1 parent 14c3d7c commit f0dd5a1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

cesium_app/handlers/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def post(self):
2929
p = Project.add_by(data['projectName'],
3030
data.get('projectDescription', ''),
3131
self.get_username())
32-
32+
self.action('cesium/FETCH_DATASETS')
3333
return self.success({"id": p.id}, 'cesium/FETCH_PROJECTS')
3434

3535
def put(self, project_id):

cesium_app/models.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313
from cesium_app.json_util import to_json
1414
from cesium_app.config import cfg
15-
from cesium import featurize
15+
from cesium import featurize, data_management
16+
17+
import shutil
18+
from os.path import join as pjoin
1619

1720

1821
db = pw.PostgresqlDatabase(autocommit=True, autorollback=True,
@@ -49,6 +52,17 @@ def add_by(name, description, username):
4952
with db.atomic():
5053
p = Project.create(name=name, description=description)
5154
UserProject.create(username=username, project=p)
55+
56+
# Add example dataset to project, similar to create_test_dataset
57+
header = pjoin(os.path.dirname(__file__),
58+
'tests', 'data', 'asas_training_subset_classes.dat')
59+
tarball = pjoin(os.path.dirname(__file__),
60+
'tests', 'data', 'asas_training_subset.tar.gz')
61+
header = shutil.copy2(header, cfg['paths']['upload_folder'])
62+
tarball = shutil.copy2(tarball, cfg['paths']['upload_folder'])
63+
ts_paths = data_management.parse_and_store_ts_data(
64+
tarball, cfg['paths']['ts_data_folder'], header)
65+
Dataset.add(name='Example Dataset', project=p, file_uris=ts_paths).save()
5266
return p
5367

5468
def is_owned_by(self, username):

0 commit comments

Comments
 (0)