-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add accelerator value to job cfg and extend PR comment if accelerator arg is used #280
Changes from all commits
cef70a7
96b067d
815f8fe
9e4cbfd
34534bb
8f44ba9
216e2db
35dac28
687c256
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
# Local application imports (anything from EESSI/eessi-bot-software-layer) | ||
from connections import github | ||
from tools import config, cvmfs_repository, job_metadata, pr_comments, run_cmd | ||
import tools.filter as tools_filter | ||
|
||
|
||
# defaults (used if not specified via, eg, 'app.cfg') | ||
|
@@ -46,7 +47,7 @@ | |
_ERROR_NONE = "none" | ||
|
||
|
||
Job = namedtuple('Job', ('working_dir', 'arch_target', 'repo_id', 'slurm_opts', 'year_month', 'pr_id')) | ||
Job = namedtuple('Job', ('working_dir', 'arch_target', 'repo_id', 'slurm_opts', 'year_month', 'pr_id', 'accelerator')) | ||
|
||
# global repo_cfg | ||
repo_cfg = {} | ||
|
@@ -474,6 +475,17 @@ def prepare_jobs(pr, cfg, event_info, action_filter): | |
# call to just before download_pr | ||
year_month, pr_id, run_dir = create_pr_dir(pr, cfg, event_info) | ||
|
||
# determine accelerator from action_filter argument | ||
accelerators = action_filter.get_filter_by_component(tools_filter.FILTER_COMPONENT_ACCEL) | ||
if len(accelerators) == 1: | ||
accelerator = accelerators[0] | ||
elif len(accelerators) > 1: | ||
log(f"{fn}(): found more than one ({len(accelerators)}) accelerator requirement") | ||
accelerator = None | ||
else: | ||
log(f"{fn}(): found no accelerator requirement") | ||
accelerator = None | ||
|
||
jobs = [] | ||
for arch, slurm_opt in arch_map.items(): | ||
arch_dir = arch.replace('/', '_') | ||
|
@@ -501,6 +513,15 @@ def prepare_jobs(pr, cfg, event_info, action_filter): | |
continue | ||
else: | ||
log(f"{fn}(): context DOES satisfy filter(s), going on with job") | ||
# we reached this point when the filter matched (otherwise we | ||
# 'continue' with the next repository) | ||
# for each match of the filter we create a specific job directory | ||
# however, matching CPU architectures works differently to handling | ||
# accelerators; multiple CPU architectures defined in arch_target_map | ||
# can match the (CPU) architecture component of a filter; in | ||
# contrast, the value of the accelerator filter is just passed down | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this rather limiting? How could we then send GPU builds to a GPU node/partition, when desired? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a separate argument for that (e.g., There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest to not add this capability in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, agreed |
||
# to scripts in bot/ directory of the pull request (see function | ||
# prepare_job_cfg and creation of Job tuple below) | ||
job_dir = os.path.join(run_dir, arch_dir, repo_id) | ||
os.makedirs(job_dir, exist_ok=True) | ||
log(f"{fn}(): job_dir '{job_dir}'") | ||
|
@@ -513,11 +534,14 @@ def prepare_jobs(pr, cfg, event_info, action_filter): | |
# prepare job configuration file 'job.cfg' in directory <job_dir>/cfg | ||
cpu_target = '/'.join(arch.split('/')[1:]) | ||
os_type = arch.split('/')[0] | ||
log(f"{fn}(): arch = '{arch}' => cpu_target = '{cpu_target}' , os_type = '{os_type}'") | ||
prepare_job_cfg(job_dir, build_env_cfg, repocfg, repo_id, cpu_target, os_type) | ||
|
||
log(f"{fn}(): arch = '{arch}' => cpu_target = '{cpu_target}' , os_type = '{os_type}'" | ||
f", accelerator = '{accelerator}'") | ||
|
||
prepare_job_cfg(job_dir, build_env_cfg, repocfg, repo_id, cpu_target, os_type, accelerator) | ||
|
||
# enlist jobs to proceed | ||
job = Job(job_dir, arch, repo_id, slurm_opt, year_month, pr_id) | ||
job = Job(job_dir, arch, repo_id, slurm_opt, year_month, pr_id, accelerator) | ||
jobs.append(job) | ||
|
||
log(f"{fn}(): {len(jobs)} jobs to proceed after applying white list") | ||
|
@@ -527,7 +551,7 @@ def prepare_jobs(pr, cfg, event_info, action_filter): | |
return jobs | ||
|
||
|
||
def prepare_job_cfg(job_dir, build_env_cfg, repos_cfg, repo_id, software_subdir, os_type): | ||
def prepare_job_cfg(job_dir, build_env_cfg, repos_cfg, repo_id, software_subdir, os_type, accelerator): | ||
""" | ||
Set up job configuration file 'job.cfg' in directory <job_dir>/cfg | ||
|
||
|
@@ -538,6 +562,7 @@ def prepare_job_cfg(job_dir, build_env_cfg, repos_cfg, repo_id, software_subdir, | |
repo_id (string): identifier of the repository to build for | ||
software_subdir (string): software subdirectory to build for (e.g., 'x86_64/generic') | ||
os_type (string): type of the os (e.g., 'linux') | ||
accelerator (string): defines accelerator to build for (e.g., 'nvidia/cc80') | ||
|
||
Returns: | ||
None (implicitly) | ||
|
@@ -563,6 +588,7 @@ def prepare_job_cfg(job_dir, build_env_cfg, repos_cfg, repo_id, software_subdir, | |
# [architecture] | ||
# software_subdir = software_subdir | ||
# os_type = os_type | ||
# accelerator = accelerator | ||
job_cfg = configparser.ConfigParser() | ||
job_cfg[job_metadata.JOB_CFG_SITE_CONFIG_SECTION] = {} | ||
build_env_to_job_cfg_keys = { | ||
|
@@ -607,6 +633,7 @@ def prepare_job_cfg(job_dir, build_env_cfg, repos_cfg, repo_id, software_subdir, | |
job_cfg[job_cfg_arch_section] = {} | ||
job_cfg[job_cfg_arch_section][job_metadata.JOB_CFG_ARCHITECTURE_SOFTWARE_SUBDIR] = software_subdir | ||
job_cfg[job_cfg_arch_section][job_metadata.JOB_CFG_ARCHITECTURE_OS_TYPE] = os_type | ||
job_cfg[job_cfg_arch_section][job_metadata.JOB_CFG_ARCHITECTURE_ACCELERATOR] = accelerator if accelerator else '' | ||
|
||
# copy contents of directory containing repository configuration to directory | ||
# containing job configuration/metadata | ||
|
@@ -726,11 +753,18 @@ def create_pr_comment(job, job_id, app_name, pr, gh, symlink): | |
# obtain arch from job.arch_target which has the format OS/ARCH | ||
arch_name = '-'.join(job.arch_target.split('/')[1:]) | ||
|
||
submitted_job_comments_cfg = config.read_config()[config.SECTION_SUBMITTED_JOB_COMMENTS] | ||
|
||
# set string for accelerator if job.accelerator is defined/set (e.g., not None) | ||
accelerator_spec_str = '' | ||
if job.accelerator: | ||
accelerator_spec = f"{submitted_job_comments_cfg[config.SUBMITTED_JOB_COMMENTS_SETTING_WITH_ACCELERATOR]}" | ||
accelerator_spec_str = accelerator_spec.format(accelerator=job.accelerator) | ||
|
||
# get current date and time | ||
dt = datetime.now(timezone.utc) | ||
|
||
# construct initial job comment | ||
submitted_job_comments_cfg = config.read_config()[config.SECTION_SUBMITTED_JOB_COMMENTS] | ||
job_comment = (f"{submitted_job_comments_cfg[config.SUBMITTED_JOB_COMMENTS_SETTING_INITIAL_COMMENT]}" | ||
f"\n|date|job status|comment|\n" | ||
f"|----------|----------|------------------------|\n" | ||
|
@@ -741,7 +775,8 @@ def create_pr_comment(job, job_id, app_name, pr, gh, symlink): | |
arch_name=arch_name, | ||
symlink=symlink, | ||
repo_id=job.repo_id, | ||
job_id=job_id) | ||
job_id=job_id, | ||
accelerator_spec=accelerator_spec_str) | ||
|
||
# create comment to pull request | ||
repo_name = pr.base.repo.full_name | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we warn or something when the list has more than 1 element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Logging is maybe sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 8f44ba9
Also logs in case there is no element.