Skip to content

Commit

Permalink
remove --login from shebang
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Aug 5, 2021
1 parent a86d9f4 commit a5b15c9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 33 deletions.
6 changes: 2 additions & 4 deletions coupledmodeldriver/generate/adcirc/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
AdcircSetupJob,
AswipCommand,
)
from coupledmodeldriver.script import EnsembleCleanupScript, \
EnsembleRunScript, SlurmEmailType
from coupledmodeldriver.utilities import LOGGER, create_symlink, \
get_logger
from coupledmodeldriver.script import EnsembleCleanupScript, EnsembleRunScript, SlurmEmailType
from coupledmodeldriver.utilities import create_symlink, get_logger, LOGGER


class RunPhase(Enum):
Expand Down
80 changes: 51 additions & 29 deletions coupledmodeldriver/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SlurmEmailType(Enum):


class Script:
shebang = '#!/bin/bash --login'
shebang = '#!/bin/bash'

def __init__(self, commands: [str]):
if commands is None:
Expand All @@ -38,7 +38,14 @@ def __init__(self, commands: [str]):
self.commands = commands

def __str__(self) -> str:
return '\n'.join([self.shebang, *(str(command) for command in self.commands)])
lines = []

if self.shebang is not None:
lines.append(self.shebang)

lines.extend(self.commands)

return '\n'.join(lines)

def write(self, filename: PathLike, overwrite: bool = False):
"""
Expand Down Expand Up @@ -205,9 +212,10 @@ def slurm_header(self) -> str:
return '\n'.join(lines)

def __str__(self) -> str:
lines = [
self.shebang,
]
lines = []

if self.shebang is not None:
lines.append(self.shebang)

if self.platform.value['uses_slurm']:
lines.extend([self.slurm_header, '', 'set -e', ''])
Expand Down Expand Up @@ -246,11 +254,18 @@ def __init__(self, platform: Platform, run_spinup: bool = True, commands: [str]
super().__init__(commands)

def __str__(self) -> str:
lines = [
*(str(command) for command in self.commands),
'DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"',
'',
]
lines = []

if self.shebang is not None:
lines.append(self.shebang)

lines.extend(
[
*(str(command) for command in self.commands),
'DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"',
'',
]
)

spinup_lines = []
if self.run_spinup:
Expand Down Expand Up @@ -333,25 +348,32 @@ def __init__(self, commands: [str] = None):
super().__init__(commands)

def __str__(self):
lines = [
*(str(command) for command in self.commands),
'DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"',
'',
'# clean spinup files',
'pushd ${DIRECTORY}/spinup >/dev/null 2>&1',
'rm -rf PE* ADC_* max* partmesh.txt metis_graph.txt fort.16 fort.6* fort.80',
'popd >/dev/null 2>&1',
'',
'# clean run configurations',
bash_for_loop(
'for hotstart in ${DIRECTORY}/runs/*/',
[
'pushd ${hotstart} >/dev/null 2>&1',
'rm -rf PE* ADC_* max* partmesh.txt metis_graph.txt fort.16 fort.63 fort.64 fort.80',
'popd >/dev/null 2>&1',
],
),
]
lines = []

if self.shebang is not None:
lines.append(self.shebang)

lines.extend(
[
*(str(command) for command in self.commands),
'DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"',
'',
'# clean spinup files',
'pushd ${DIRECTORY}/spinup >/dev/null 2>&1',
'rm -rf PE* ADC_* max* partmesh.txt metis_graph.txt fort.16 fort.6* fort.80',
'popd >/dev/null 2>&1',
'',
'# clean run configurations',
bash_for_loop(
'for hotstart in ${DIRECTORY}/runs/*/',
[
'pushd ${hotstart} >/dev/null 2>&1',
'rm -rf PE* ADC_* max* partmesh.txt metis_graph.txt fort.16 fort.63 fort.64 fort.80',
'popd >/dev/null 2>&1',
],
),
]
)

return '\n'.join(lines)

Expand Down

0 comments on commit a5b15c9

Please sign in to comment.