Skip to content

Commit

Permalink
Provide default app configuration, as part of #751.
Browse files Browse the repository at this point in the history
  • Loading branch information
donkirkby committed Feb 11, 2019
1 parent 14329d7 commit 78ea6e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions kive/container/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ class Meta(object):

class ContainerForm(PermissionsForm):
parent = forms.ModelChoiceField(
help_text=Container.parent.field.help_text,
queryset=Container.objects.filter(file_type=Container.SIMG))
help_text=Container.parent.field.help_text,
queryset=Container.objects.filter(file_type=Container.SIMG),
required=False)

class Meta(object):
model = Container
Expand Down
7 changes: 4 additions & 3 deletions kive/container/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class Container(AccessControl):
(".tar", TAR)
]
)
DEFAULT_APP_CONFIG = dict(memory=5000, threads=1)

accepted_extensions = ACCEPTED_FILE_EXTENSIONS.keys()
if dsix.PY3:
Expand Down Expand Up @@ -362,8 +363,7 @@ def get_content(self):
pipeline_json = archive.read(last_entry)
pipeline = json.loads(pipeline_json)
else:
pipeline = dict(default_config=dict(memory=5000,
threads=1),
pipeline = dict(default_config=self.DEFAULT_APP_CONFIG,
inputs=[],
steps=[],
outputs=[])
Expand Down Expand Up @@ -391,7 +391,8 @@ def write_content(self, content):
len(pipeline['outputs'])) > 0
if is_valid:
self.apps.all().delete()
default_config = pipeline['default_config']
default_config = pipeline.get('default_config',
self.DEFAULT_APP_CONFIG)
app = self.apps.create(memory=default_config['memory'],
threads=default_config['threads'])
input_names = ' '.join(entry['dataset_name']
Expand Down

0 comments on commit 78ea6e0

Please sign in to comment.