From 3aa5e8fe6640b72111b179568afb530fa15f49ab Mon Sep 17 00:00:00 2001 From: vapao Date: Sun, 12 Mar 2023 23:41:20 +0800 Subject: [PATCH] update pipeline module --- spug_api/apps/pipeline/utils.py | 5 ++++- spug_api/apps/pipeline/views.py | 15 +++++++++------ spug_api/libs/gitlib.py | 6 +----- spug_web/src/pages/pipeline/Node.js | 2 +- spug_web/src/pages/pipeline/NodeConfig.js | 6 +++--- .../src/pages/pipeline/nodeConfig.module.less | 2 +- spug_web/src/pages/pipeline/store.js | 9 ++++----- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/spug_api/apps/pipeline/utils.py b/spug_api/apps/pipeline/utils.py index 85d6a91..04f60aa 100644 --- a/spug_api/apps/pipeline/utils.py +++ b/spug_api/apps/pipeline/utils.py @@ -147,8 +147,11 @@ class NodeExecutor: command = f'sshfs -o ro -o ssh_command="ssh -p {host.port} -i {fp.name}" {remote_dir} {local_dir}' task = subprocess.run(command, shell=True, capture_output=True) if task.returncode != 0: + error_msg = task.stderr.decode() os.system(f'umount -f {local_dir} &> /dev/null ; rm -rf {local_dir}') - return self.helper.send_error(node.id, task.stderr.decode()) + for host_id in destination.targets: + self.helper.send_error(f'{node.id}.{host_id}', error_msg) + return self.helper.send_error(node.id, error_msg) threads = [] with futures.ThreadPoolExecutor(max_workers=self.max_workers) as executor: diff --git a/spug_api/apps/pipeline/views.py b/spug_api/apps/pipeline/views.py index e4089fe..6f3e12e 100644 --- a/spug_api/apps/pipeline/views.py +++ b/spug_api/apps/pipeline/views.py @@ -97,7 +97,12 @@ class DoView(View): if item['module'] == 'parameter': dynamic_params = item.get('dynamic_params') elif item['module'] == 'data_upload': - dynamic_params.append({'id': item['id'], 'name': item['name'], 'type': 'upload'}) + tmp = {'variable': item['id'], 'name': item['name'], 'type': 'upload', 'required': True} + if 'accept' in item: + tmp['accept'] = item['accept'] + if 'size' in item: + tmp['size'] = item['size'] + dynamic_params.append(tmp) token = uuid4().hex if dynamic_params: @@ -120,13 +125,11 @@ class DoView(View): Argument('id', type=int, help='参数错误'), Argument('token', help='参数错误'), Argument('params', type=dict, help='参数错误'), - Argument('cols', type=int, required=False), - Argument('rows', type=int, required=False) ).parse(request.body) if error is None: - term = None - if form.cols and form.rows: - term = {'width': form.cols, 'height': form.rows} + for k, v in form.params.items(): + if isinstance(v, list): + form.params[k] = ','.join(v) pipe = Pipeline.objects.get(pk=form.id) nodes = json.loads(pipe.nodes) for item in nodes: diff --git a/spug_api/libs/gitlib.py b/spug_api/libs/gitlib.py index 80d79a0..f7a7dde 100644 --- a/spug_api/libs/gitlib.py +++ b/spug_api/libs/gitlib.py @@ -152,8 +152,7 @@ class RemoteGit: def _clone(self): env = self._make_ask_env() - print(env) - return self.remote_exec(f'git clone {self.url} {self.path}', env) + return self.remote_exec(f'git clone {self.url} {self.path}', env) def set_remote_exec(self, remote_exec): self.remote_exec = partial(remote_exec, self.ssh) @@ -176,7 +175,6 @@ class RemoteGit: ask_file.flush() os.chmod(ask_file.name, 0o755) env.update(GIT_ASKPASS=ask_file.name) - print(ask_file.name) else: key_file = NamedTemporaryFile() key_file.write(credential.secret.encode()) @@ -188,8 +186,6 @@ class RemoteGit: ask_file.flush() os.chmod(ask_file.name, 0o755) env.update(GIT_SSH=ask_file.name) - print(ask_file.name) - print(key_file.name) command = f'git ls-remote -h {url} HEAD' res = subprocess.run(command, shell=True, capture_output=True, env=env) diff --git a/spug_web/src/pages/pipeline/Node.js b/spug_web/src/pages/pipeline/Node.js index ee65c37..1a6d408 100644 --- a/spug_web/src/pages/pipeline/Node.js +++ b/spug_web/src/pages/pipeline/Node.js @@ -80,7 +80,7 @@ function Node(props) { {node.name ? (
{node.name}
) : ( -
请选择节点
+
请选择节点模块
)} diff --git a/spug_web/src/pages/pipeline/NodeConfig.js b/spug_web/src/pages/pipeline/NodeConfig.js index 20fc65f..2364888 100644 --- a/spug_web/src/pages/pipeline/NodeConfig.js +++ b/spug_web/src/pages/pipeline/NodeConfig.js @@ -57,16 +57,16 @@ function NodeConfig(props) {
setTab('node')}> - 选择节点 + 选择模块
setTab('conf')}> - 节点配置 + 模块配置
-
内置节点
+
内置模块
{NODES.map(item => (
{ this.record = record - return http.post('/api/pipeline/do/', {id: 1}) + return http.post('/api/pipeline/do/', {id: record.id}) .then(res => { - S.open = true + S.record = record S.token = res.token S.nodes = res.nodes S.node = res.nodes[0] - if (res.dynamic_params) { - S.dynamicParams = res.dynamic_params - } + S.outputs = {} + S.dynamicParams = res.dynamic_params ? res.dynamic_params : null }) } }