Skip to content
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

Fix job array display. #1723

Draft
wants to merge 11 commits into
base: xdmod11.0
Choose a base branch
from
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 @@ public function getQueryTableDefinitions($realm)
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(
'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 @@ -1316,7 +1316,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 @@ -1466,7 +1466,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 @@ -1481,11 +1481,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 @@ -2068,7 +2068,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 @@ -116,6 +116,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 @@ -376,6 +383,7 @@
"documentation": "${HIERARCHY_BOTTOM_LEVEL_INFO}",
"batchExport": true
}
]
],
"record_identifier_column": "local_job_id_raw"
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function testGetRealmsTokenAuth($role, $tokenType) {
$index++;
}

$counts = [28, 16, 16];
$counts = [29, 16, 16];
for ($i = 0; $i < count($counts); $i++) {
$this->assertCount(
$counts[$i],
Expand Down