forked from PanDAWMS/pilot3
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paul Nilsson
committed
Dec 5, 2023
1 parent
89a0d76
commit 9d78972
Showing
4 changed files
with
57 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,24 +19,30 @@ | |
# Authors: | ||
# - Paul Nilsson, [email protected], 2019-23 | ||
|
||
from pilot.util.container import execute | ||
from pilot.common.errorcodes import ErrorCodes | ||
from ..setup import get_asetup, get_asetup_options | ||
"""Default grid resources.""" | ||
|
||
import logging | ||
from typing import Any | ||
|
||
from pilot.common.errorcodes import ErrorCodes | ||
from pilot.util.container import execute | ||
from ..setup import ( | ||
get_asetup, | ||
get_asetup_options | ||
) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
errors = ErrorCodes() | ||
|
||
|
||
def verify_setup_command(cmd): | ||
def verify_setup_command(cmd: str) -> (int, str): | ||
""" | ||
Verify the setup command (containerised). | ||
:param cmd: command string to be verified (string). | ||
:return: pilot error code (int), diagnostics (string). | ||
:param cmd: command string to be verified (str) | ||
:return: pilot error code (int), diagnostics (str). | ||
""" | ||
|
||
diagnostics = "" | ||
|
||
exit_code, stdout, stderr = execute(cmd, timeout=5 * 60) | ||
|
@@ -52,32 +58,32 @@ def verify_setup_command(cmd): | |
return exit_code, diagnostics | ||
|
||
|
||
def get_setup_command(job, prepareasetup): | ||
def get_setup_command(job: Any, prepareasetup: bool = True) -> str: | ||
""" | ||
Return the path to asetup command, the asetup command itself and add the options (if desired). | ||
If prepareasetup is False, the function will only return the path to the asetup script. It is then assumed | ||
to be part of the job parameters. | ||
:param job: job object. | ||
:param prepareasetup: should the pilot prepare the asetup command itself? boolean. | ||
:return: | ||
:param job: job object (Any) | ||
:param prepareasetup: should the pilot prepare the asetup command itself? (bool) | ||
:return: command string (str). | ||
""" | ||
|
||
# if cvmfs is not available, assume that asetup is not needed | ||
# note that there is an exception for sites (BOINC, some HPCs) that have cvmfs but still | ||
# uses is_cvmfs=False.. these sites do not use containers, so check for that instead | ||
if job.infosys.queuedata.is_cvmfs or not job.infosys.queuedata.container_type: | ||
logger.debug('return asetup path as normal since: is_cvmfs=%s, job.container_type=%s' % | ||
(job.infosys.queuedata.is_cvmfs, job.infosys.queuedata.container_type)) | ||
logger.debug(f'return asetup path as normal since: is_cvmfs={job.infosys.queuedata.is_cvmfs}, ' | ||
f'job.container_type={job.infosys.queuedata.container_type}') | ||
else: | ||
# if not job.infosys.queuedata.is_cvmfs: | ||
logger.debug('will not return asetup path since: is_cvmfs=%s, job.container_type=%s' % | ||
(job.infosys.queuedata.is_cvmfs, job.infosys.queuedata.container_type)) | ||
logger.debug(f'will not return asetup path since: is_cvmfs={job.infosys.queuedata.is_cvmfs}, ' | ||
f'job.container_type={job.infosys.queuedata.container_type}') | ||
return "" | ||
|
||
# return immediately if there is no release or if user containers are used | ||
# if job.swrelease == 'NULL' or (('--containerImage' in job.jobparams or job.imagename) and job.swrelease == 'NULL'): | ||
if job.swrelease == 'NULL' or job.swrelease == '': | ||
if job.swrelease in {'NULL', ''}: | ||
logger.debug('will not return asetup path since there is no swrelease set') | ||
return "" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ | |
# | ||
# Authors: | ||
# - Paul Nilsson, [email protected], 2019-23 | ||
|
||
"""Resource related functions for jumbo jobs (nothing so far).""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,46 +19,50 @@ | |
# Authors: | ||
# - Paul Nilsson, [email protected], 2019-23 | ||
|
||
"""Resource related functions for many-to-one jobs.""" | ||
|
||
import logging | ||
import os | ||
from typing import Any | ||
|
||
# from pilot.util.container import execute | ||
from pilot.common.errorcodes import ErrorCodes | ||
|
||
import logging | ||
logger = logging.getLogger(__name__) | ||
|
||
errors = ErrorCodes() | ||
|
||
|
||
def verify_setup_command(cmd): | ||
def verify_setup_command(cmd: str) -> (int, str): | ||
""" | ||
Verify the setup command. | ||
:param cmd: command string to be verified (string). | ||
:return: pilot error code (int), diagnostics (string). | ||
:param cmd: command string to be verified (str) | ||
:return: pilot error code (int), diagnostics (str). | ||
""" | ||
if not cmd: | ||
logger.debug('cmd is not used by this function') | ||
|
||
ec = 0 | ||
diagnostics = "" | ||
return 0, "" | ||
|
||
return ec, diagnostics | ||
|
||
|
||
def get_setup_command(job, prepareasetup): | ||
def get_setup_command(job: Any, prepareasetup: bool) -> str: | ||
""" | ||
Return the path to asetup command, the asetup command itself and add the options (if desired). | ||
If prepareasetup is False, the function will only return the path to the asetup script. It is then assumed | ||
to be part of the job parameters. | ||
Handle the case where environmental variables are set - | ||
HARVESTER_CONTAINER_RELEASE_SETUP_FILE, HARVESTER_LD_LIBRARY_PATH, HARVESTER_PYTHONPATH | ||
This will create the string need for the pilot to execute to setup the environment. | ||
:param job: job object. | ||
:param prepareasetup: not used. | ||
:return: setup command (string). | ||
:param job: job object (Any) | ||
:param prepareasetup: not used (bool) | ||
:return: setup command (str). | ||
""" | ||
|
||
if not prepareasetup: | ||
logger.debug('prepareasetup is not used by this function') | ||
cmd = "" | ||
|
||
# return immediately if there is no release or if user containers are used | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,46 +19,49 @@ | |
# Authors: | ||
# - Paul Nilsson, [email protected], 2019-23 | ||
|
||
"""Resource related functions for NERSC.""" | ||
|
||
import logging | ||
import os | ||
from typing import Any | ||
|
||
# from pilot.util.container import execute | ||
from pilot.common.errorcodes import ErrorCodes | ||
|
||
import logging | ||
logger = logging.getLogger(__name__) | ||
|
||
errors = ErrorCodes() | ||
|
||
|
||
def verify_setup_command(cmd): | ||
def verify_setup_command(cmd: str) -> (int, str): | ||
""" | ||
Verify the setup command. | ||
:param cmd: command string to be verified (string). | ||
:return: pilot error code (int), diagnostics (string). | ||
""" | ||
if not cmd: | ||
logger.debug('cmd is not used by this function') | ||
|
||
ec = 0 | ||
diagnostics = "" | ||
return 0, "" | ||
|
||
return ec, diagnostics | ||
|
||
|
||
def get_setup_command(job, prepareasetup): | ||
def get_setup_command(job: Any, prepareasetup: bool) -> str: | ||
""" | ||
Return the path to asetup command, the asetup command itself and add the options (if desired). | ||
If prepareasetup is False, the function will only return the path to the asetup script. It is then assumed | ||
to be part of the job parameters. | ||
Handle the case where environmental variables are set - | ||
HARVESTER_CONTAINER_RELEASE_SETUP_FILE, HARVESTER_LD_LIBRARY_PATH, HARVESTER_PYTHONPATH | ||
This will create the string need for the pilot to execute to setup the environment. | ||
:param job: job object. | ||
:param prepareasetup: not used. | ||
:return: setup command (string). | ||
:param job: job object (Any) | ||
:param prepareasetup: not used (bool) | ||
:return: setup command (str). | ||
""" | ||
|
||
if not prepareasetup: | ||
logger.debug('prepareasetup is not used by this function') | ||
cmd = "" | ||
|
||
# return immediately if there is no release or if user containers are used | ||
|