update pipeline module

4.0
vapao 2023-03-12 23:41:20 +08:00
parent 6809eb95cd
commit 3aa5e8fe66
7 changed files with 23 additions and 22 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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)

View File

@ -80,7 +80,7 @@ function Node(props) {
{node.name ? (
<div className={css.title}>{node.name}</div>
) : (
<div className={css.title} style={{color: '#595959'}}>请选择节点</div>
<div className={css.title} style={{color: '#595959'}}>请选择节点模块</div>
)}
<Dropdown dropdownRender={dropdownRender} className={css.action}
trigger="click" menu={{items: menus}} onMouseDown={handleActionClick}>

View File

@ -57,16 +57,16 @@ function NodeConfig(props) {
<div className={css.header}>
<div className={clsNames(css.item, tab === 'node' && css.active)} onClick={() => setTab('node')}>
<AppstoreOutlined/>
<span>选择节点</span>
<span>选择模块</span>
</div>
<div className={clsNames(css.item, tab === 'conf' && css.active)} onClick={() => setTab('conf')}>
<SettingOutlined/>
<span>节点配置</span>
<span>模块配置</span>
</div>
</div>
<div style={{marginTop: 72, display: tab === 'node' ? 'block' : 'none'}}>
<div className={css.category}>内置节点</div>
<div className={css.category}>内置模块</div>
<div className={css.items}>
{NODES.map(item => (
<div key={item.module} className={clsNames(css.item, S.node?.module === item.module && css.active)}

View File

@ -11,8 +11,8 @@
align-items: flex-end;
.item {
width: 100px;
height: 40px;
padding: 0 10px;
border-radius: 6px 6px 0 0;
display: flex;
flex-direction: row;

View File

@ -46,15 +46,14 @@ class Store {
showConsole = (record) => {
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
})
}
}