Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Overload get_output_path for gWasm tasks
Browse files Browse the repository at this point in the history
This commit overloads the `TaskBuilder`'s `get_output_path` for
gWasm tasks. If the task def consists of `output_path` field, then
its value is used as the output path of the task. Otherwise,
`get_output_path` returns the value of `output_dir` that is
supplied within the task def.

This commit partially addresses golemfactory/g-flite#28.

cc @mdtanrikulu FYI, this commit together with golemfactory/g-flite#33
and golemfactory/gwasm-rust-api#10 should address
golemfactory/g-flite#28.
  • Loading branch information
Jakub Konka committed Oct 31, 2019
1 parent f3f8b25 commit 13071e0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions apps/wasm/task.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from dataclasses import dataclass
from copy import deepcopy
from pathlib import Path, PurePath
Expand Down Expand Up @@ -551,15 +552,13 @@ class WasmTaskBuilder(CoreTaskBuilder):
def build_full_definition(
cls, task_type: 'CoreTaskTypeInfo',
dictionary: Dict[str, Any]) -> TaskDefinition:
options = dictionary['options']
# Resources are generated from 'input_dir' later on.
dictionary['resources'] = []
# Output is determined from 'output_dir' later on.
dictionary['options']['output_path'] = ''
# Subtasks count is determined by the amount of subtask info provided.
dictionary['subtasks_count'] = len(dictionary['options']['subtasks'])
dictionary['subtasks_count'] = len(options['subtasks'])

task_def: Any = super().build_full_definition(task_type, dictionary)
options = dictionary['options']
task_def.options.js_name = options['js_name']
task_def.options.wasm_name = options['wasm_name']
task_def.options.input_dir = options['input_dir']
Expand All @@ -580,6 +579,20 @@ def build_full_definition(

return task_def

@classmethod
def get_output_path(
cls,
dictionary: Dict[str, Any],
definition: 'TaskDefinition') -> str:
options = dictionary['options']

if 'output_path' in options:
output_path = options['output_path']
else:
output_path = options['output_dir']

return os.path.join(output_path, '/')


class WasmBenchmarkTask(WasmTask):
def query_extra_data(self, perf_index: float,
Expand Down

0 comments on commit 13071e0

Please sign in to comment.