Skip to content

Commit

Permalink
debug task submission
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Aug 31, 2021
1 parent 31f5dab commit 13cfd91
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 44 deletions.
69 changes: 46 additions & 23 deletions plantit/front_end/src/components/workflows/workflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,12 @@
class="mt-1"
>
<b-col>
<b-form-input :class="profile.darkMode ? 'input-dark' : 'input-light'"
<b-form-input
:class="
profile.darkMode
? 'input-dark'
: 'input-light'
"
v-model="
taskName
"
Expand Down Expand Up @@ -1443,7 +1448,11 @@
>
<b-col>
<multiselect
:class="profile.darkMode ? 'input-dark' : 'input-light'"
:class="
profile.darkMode
? 'input-dark'
: 'input-light'
"
style="z-index: 100"
v-model="
tags
Expand Down Expand Up @@ -1806,7 +1815,11 @@
filetypes.
</b>
<multiselect
:class="profile.darkMode ? 'input-dark' : 'input-light'"
:class="
profile.darkMode
? 'input-dark'
: 'input-light'
"
:multiple="
true
"
Expand Down Expand Up @@ -2034,7 +2047,11 @@
patterns.
</b>
<multiselect
:class="profile.darkMode ? 'input-dark' : 'input-light'"
:class="
profile.darkMode
? 'input-dark'
: 'input-light'
"
:multiple="
true
"
Expand Down Expand Up @@ -2103,7 +2120,11 @@
name.
</b>
<multiselect
:class="profile.darkMode ? 'input-dark' : 'input-light'"
:class="
profile.darkMode
? 'input-dark'
: 'input-light'
"
:multiple="
true
"
Expand Down Expand Up @@ -3805,20 +3826,21 @@
ok-variant="success"
>
<b-form-group description="Enter your username.">
<b-form-input
v-model="authenticationUsername"
type="text"
placeholder="Your username"
required
></b-form-input></b-form-group>
<b-form-group description="Enter your password.">
<b-form-input
v-model="authenticationPassword"
type="password"
placeholder="Your password"
required
></b-form-input>
</b-form-group>
<b-form-input
v-model="authenticationUsername"
type="text"
placeholder="Your username"
required
></b-form-input
></b-form-group>
<b-form-group description="Enter your password.">
<b-form-input
v-model="authenticationPassword"
type="password"
placeholder="Your password"
required
></b-form-input>
</b-form-group>
</b-modal>
<b-modal
id="unbind"
Expand Down Expand Up @@ -4406,11 +4428,12 @@ export default {
? this.inputSelectedPatterns
: this.input.filetypes;
}
config.output = this.getWorkflow.config.output;
if (this.output !== undefined && this.output.to) {
// config.output['to'] = config['output']['path'];
// config.output['from'] = '';
config.output = {};
config.output['to'] = this.output.to;
if (this.getWorkflow.config.output.path !== undefined)
config.output['from'] = this.getWorkflow.config.output.path;
else config.output['from'] = '';
if (config.output.include === undefined)
config.output['include'] = {
patterns: [],
Expand Down
45 changes: 24 additions & 21 deletions plantit/plantit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,9 @@ def compose_task_zip_command(task: Task, options: PlantITCLIOptions) -> str:
output['include']['names'] = output['include']['names'] + task.workflow['config']['output']['include']['names']
if 'exclude' in config['output']:
if 'patterns' in config['output']['exclude']:
output['exclude']['patterns'] = output['exclude']['patterns'] + task.workflow['config']['output']['exclude']['patterns']
output['exclude']['patterns'] = set(output['exclude']['patterns'] + task.workflow['config']['output']['exclude']['patterns'])
if 'names' in config['output']['exclude']:
output['exclude']['names'] = output['exclude']['names'] + task.workflow['config']['output']['exclude']['names']
output['exclude']['names'] = set(output['exclude']['names'] + task.workflow['config']['output']['exclude']['names'])

command = f"plantit zip {output['from'] if 'from' in output and output['from'] != '' else '.'} -o . -n {task.guid}"
logs = [f"{task.guid}.{task.agent.name.lower()}.log"]
Expand Down Expand Up @@ -1385,29 +1385,32 @@ def get_task_scheduler_log_file_path(task: Task):

def get_remote_logs(log_file_name: str, log_file_path: str, task: Task, ssh: SSH, sftp):
work_dir = join(task.agent.workdir, task.workdir)
cmd = 'test -e {0} && echo exists'.format(join(work_dir, log_file_name))
stdin, stdout, stderr = ssh.client.exec_command(cmd)

if not stdout.read().decode().strip() == 'exists':
logger.warning(f"Agent log file {log_file_name} does not exist")
else:
log_path = join(work_dir, log_file_name)
# cmd = f"test -e {log_path} && echo exists"
# logger.info(f"Using command: {cmd}")
# stdin, stdout, stderr = ssh.client.exec_command(cmd)
# if not stdout.read().decode().strip() == 'exists':
# logger.warning(f"Agent log file {log_file_name} does not exist")
try:
with open(log_file_path, 'a+') as log_file:
sftp.chdir(work_dir)
sftp.get(log_file_name, log_file.name)
except:
logger.warning(f"Agent log file {log_file_name} does not exist")

# obfuscate Docker auth info before returning logs to the user
docker_username = environ.get('DOCKER_USERNAME', None)
docker_password = environ.get('DOCKER_PASSWORD', None)
lines = 0
for line in fileinput.input([log_file_path], inplace=True):
if docker_username in line.strip():
line = line.strip().replace(docker_username, '*' * 7, 1)
if docker_password in line.strip():
line = line.strip().replace(docker_password, '*' * 7)
lines += 1
sys.stdout.write(line)

logger.info(f"Retrieved {lines} line(s) from {log_file_name}")
# obfuscate Docker auth info before returning logs to the user
docker_username = environ.get('DOCKER_USERNAME', None)
docker_password = environ.get('DOCKER_PASSWORD', None)
lines = 0
for line in fileinput.input([log_file_path], inplace=True):
if docker_username in line.strip():
line = line.strip().replace(docker_username, '*' * 7, 1)
if docker_password in line.strip():
line = line.strip().replace(docker_password, '*' * 7)
lines += 1
sys.stdout.write(line)

logger.info(f"Retrieved {lines} line(s) from {log_file_name}")


def get_task_remote_logs(task: Task, ssh: SSH):
Expand Down

0 comments on commit 13cfd91

Please sign in to comment.