Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions classes/DataWarehouse/Data/RawStatisticsConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,24 @@
return $realmConfig['tables'];
}

/**
* Get the column name to use when looking up a record in the job viewer
*
* @param string $realm The name of a realm.
* @return string
*/
public function getRecordIdentifierColumn($realm)
{
$realmConfig = $this->getRealmConfiguration($realm);
if (!array_key_exists('record_identifier_column', $realmConfig)) {
throw new Exception(sprintf(

Check warning on line 169 in classes/DataWarehouse/Data/RawStatisticsConfiguration.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define and throw a dedicated exception instead of using a generic one.

See more on https://sonarcloud.io/project/issues?id=ubccr_xdmod&issues=AZ1PU9UnDjkrgjePlyaP&open=AZ1PU9UnDjkrgjePlyaP&pullRequest=1723
'Record Identifier setting not found for realm "%s"',
$realm
));
}
return $realmConfig['record_identifier_column'];
}

/**
* Get the field definitions for generating a query.
*
Expand Down
2 changes: 1 addition & 1 deletion classes/DataWarehouse/Query/Cloud/JobDataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function __construct(
$this->joinTo($st, "systemaccount_id", "username", "username");

} else {
$this->addField(new TableField($factTable, "provider_identifier", "local_job_id"));
$this->addField(new TableField($factTable, "provider_identifier", "provider_job_id"));
$this->addField(new TableField($factTable, "instance_id", "jobid"));

$rt = new Table(new Schema("modw"), "resourcefact", "rf");
Expand Down
2 changes: 1 addition & 1 deletion classes/DataWarehouse/Query/Cloud/RawData.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __construct(
$this->addField(new TableField($resourcefactTable, "code", 'resource'));
$this->addField(new TableField($personTable, "long_name", "name"));

$this->addField(new TableField($factTable, "provider_identifier", "local_job_id"));
$this->addField(new TableField($factTable, "provider_identifier", "provider_job_id"));
$this->addField(new TableField($factTable, "instance_id", "jobid"));

$this->addTable($factTable);
Expand Down
3 changes: 2 additions & 1 deletion classes/DataWarehouse/Query/Gateways/JobDataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ public function __construct(
}
} else {
$this->addField(new TableField($factTable, "job_id", "jobid"));
$this->addField(new TableField($factTable, "local_jobid", "local_job_id"));
$fta = $factTable->getAlias();
$this->addField(new FormulaField("CASE WHEN $fta.local_job_array_index = -1 THEN $fta.local_jobid ELSE CONCAT($fta.local_jobid, '[', $fta.local_job_array_index, ']') END", "provider_job_id"));

$rt = new Table(new Schema("modw"), "resourcefact", "rf");
$this->joinTo($rt, "task_resource_id", "code", "resource");
Expand Down
4 changes: 3 additions & 1 deletion classes/DataWarehouse/Query/Gateways/RawData.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ public function __construct(
$this->addField(new TableField($personTable, "long_name", "name"));

$this->addField(new TableField($factTable, "job_id", "jobid"));
$this->addField(new TableField($factTable, "local_jobid", "local_job_id"));
$fta = $factTable->getAlias();
$this->addField(new FormulaField("CASE WHEN $fta.local_job_array_index = -1 THEN $fta.local_jobid ELSE CONCAT($fta.local_jobid, '[', $fta.local_job_array_index, ']') END", "provider_job_id"));
$this->addField(new TableField($factTable, 'start_time_ts'));
$this->addField(new TableField($factTable, 'end_time_ts'));
$this->addField(new FormulaField('-1', 'cpu_user'));
$this->addField(new FormulaField('COALESCE(LEAST(jt.wallduration / jt.timelimit, 1), -1)', 'walltime_accuracy'));

// This is used by Integrations and not currently shown on the XDMoD interface
$this->addField(new TableField($factTable, 'name', 'job_name'));
Expand Down
6 changes: 3 additions & 3 deletions classes/DataWarehouse/Query/Jobs/JobDataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public function __construct(

// This table is defined in the configuration file, but used in the section below.
$factTable = $tables['jt'];

if (isset($parameters['primary_key'])) {
$this->addPdoWhereCondition(new WhereCondition(new TableField($factTable, 'job_id'), "=", $parameters['primary_key']));
} elseif (isset($parameters['job_identifier'])) {
Expand All @@ -62,7 +61,7 @@ public function __construct(
$this->addPdoWhereCondition(new WhereCondition(new TableField($factTable, 'local_jobid'), '=', $matches[1]));
$this->addPdoWhereCondition(new WhereCondition(new TableField($factTable, 'local_job_array_index'), '=', $matches[2]));
} else {
$this->addPdoWhereCondition(new WhereCondition(new TableField($factTable, 'local_job_id_raw'), '=', $matches[1]));
$this->addPdoWhereCondition(new WhereCondition(new TableField($factTable, $config->getRecordIdentifierColumn('Jobs')), '=', $matches[1]));
}
} else {
throw new Exception('invalid "job_identifier" query parameter');
Expand Down Expand Up @@ -149,7 +148,8 @@ public function __construct(
}
} else {
$this->addField(new TableField($factTable, "job_id", "jobid"));
$this->addField(new TableField($factTable, "local_jobid", "local_job_id"));
$fta = $factTable->getAlias();
$this->addField(new FormulaField("CASE WHEN $fta.local_job_array_index = -1 THEN $fta.local_jobid ELSE CONCAT($fta.local_jobid, '[', $fta.local_job_array_index, ']') END", "provider_job_id"));

$rt = new Table(new Schema("modw"), "resourcefact", "rf");
$this->joinTo($rt, "task_resource_id", "code", "resource");
Expand Down
3 changes: 2 additions & 1 deletion classes/DataWarehouse/Query/Jobs/RawData.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public function __construct(
$this->addField(new TableField($personTable, "long_name", "name"));

$this->addField(new TableField($factTable, "job_id", "jobid"));
$this->addField(new TableField($factTable, "local_jobid", "local_job_id"));
$fta = $factTable->getAlias();
$this->addField(new FormulaField("CASE WHEN $fta.local_job_array_index = -1 THEN $fta.local_jobid ELSE CONCAT($fta.local_jobid, '[', $fta.local_job_array_index, ']') END", "provider_job_id"));
$this->addField(new TableField($factTable, 'start_time_ts'));
$this->addField(new TableField($factTable, 'end_time_ts'));
$this->addField(new FormulaField('-1', 'cpu_user'));
Expand Down
11 changes: 6 additions & 5 deletions classes/Rest/Controllers/WarehouseControllerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ public function processJobSearch(Request $request, Application $app, XDUser $use
$data = array();
foreach ($raw as $row) {
$resource = $row['resource'];
$localJobId = $row['local_job_id'];
$localJobId = $row['provider_job_id'];

$row['text'] = "$resource-$localJobId";
$row['dtype'] = 'jobid';
Expand Down Expand Up @@ -1516,7 +1516,7 @@ protected function getJobPeers(Application $app, XDUser $user, $realm, $jobId, $
'ref' => array(
'realm' => $realm,
'jobid' => $jobId,
"text" => $thisjob['resource'] . '-' . $thisjob['local_job_id']
"text" => $thisjob['resource'] . '-' . $thisjob['provider_job_id']
)
)
);
Expand All @@ -1531,11 +1531,11 @@ protected function getJobPeers(Application $app, XDUser $user, $realm, $jobId, $
'ref' => array(
'realm' => $realm,
'jobid' => $jobpeer['jobid'],
'local_job_id' => $jobpeer['local_job_id'],
'local_job_id' => $jobpeer['provider_job_id'],
'resource' => $jobpeer['resource']
)
);
$result['categories'][] = $jobpeer['resource'] . '-' . $jobpeer['local_job_id'];
$result['categories'][] = $jobpeer['resource'] . '-' . $jobpeer['provider_job_id'];
}
}

Expand Down Expand Up @@ -2118,7 +2118,8 @@ private function getJobByPrimaryKey(Application $app, \XDUser $user, $realm, $se

$results = array();
foreach ($dataSet->getResults() as $result) {
$result['text'] = $result['resource'] . "-" . $result['local_job_id'];
$result['text'] = $result['resource'] . "-" . $result['provider_job_id'];
$result['local_job_id'] = $result['provider_job_id'];
$result['dtype'] = 'jobid';
array_push($results, $result);
}
Expand Down
10 changes: 9 additions & 1 deletion configuration/rawstatistics.d/20_jobs.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@
"documentation": "The unique identifier assigned to the job by the job scheduler.",
"batchExport": true
},
{
"name": "Local Job Id Raw",
"formula": "local_job_id_raw",
"group": "Administration",
"documentation": "A unique identifier assigned to the job by the job scheduler. This field will be identical to the Local Job Id field except for array jobs for the Slurm scheduler. In the case of Slurm array jobs this will be the internal identifier for the job.",
"batchExport": true
},
{
"name": "Resource",
"tableAlias": "rf",
Expand Down Expand Up @@ -430,6 +437,7 @@
"documentation": "${HIERARCHY_BOTTOM_LEVEL_INFO}",
"batchExport": true
}
]
],
"record_identifier_column": "local_job_id_raw"
}
}
Loading