Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Adding reproduction command to tracker scalars.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpatrick committed Jan 15, 2016
1 parent eaf57a0 commit 3783a6d
Show file tree
Hide file tree
Showing 8 changed files with 324 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/tracker/configs/module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description = "Track scalar results over time"
category = "Visualization"
dependencies = api,scheduler
uuid = "3048a9fa-89ab-4e61-a55e-a49379fa6dc"
version = "1.2.2"
version = "1.2.3"
9 changes: 8 additions & 1 deletion modules/tracker/controllers/components/ApiComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function itemAssociate($args)
* @param silent (Optional) If set, do not perform threshold-based email notifications for this scalar
* @param unofficial (Optional) If passed, creates an unofficial scalar visible only to the user performing the submission
* @param unit (Optional) If passed, the unit of the scalar value that identifies which trend this point belongs to.
* @param reproductionCommand (Optional) If passed, the command to produce this scalar
* @return The scalar DAO that was created
* @throws Exception
*/
Expand Down Expand Up @@ -280,6 +281,11 @@ public function scalarAdd($args)
$submissionId = $submissionDao->getKey();
}

$reproductionCommand = null;
if (isset($args['reproductionCommand'])) {
$reproductionCommand = $args['reproductionCommand'];
}

/** @var Tracker_ScalarModel $scalarModel */
$scalarModel = MidasLoader::loadModel('Scalar', 'tracker');
$scalar = $scalarModel->addToTrend(
Expand All @@ -294,7 +300,8 @@ public function scalarAdd($args)
$buildResultsUrl,
$branch,
$extraParams,
$extraUrls
$extraUrls,
$reproductionCommand
);

if (!isset($args['silent'])) {
Expand Down
89 changes: 89 additions & 0 deletions modules/tracker/database/mysql/1.2.3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
-- Midas Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- MySQL database for the tracker module, version 1.2.2

CREATE TABLE IF NOT EXISTS `tracker_producer` (
`producer_id` bigint(20) NOT NULL AUTO_INCREMENT,
`community_id` bigint(20) NOT NULL,
`repository` varchar(255) NOT NULL,
`executable_name` varchar(255) NOT NULL,
`display_name` varchar(255) NOT NULL,
`description` text NOT NULL,
`revision_url` text NOT NULL,
PRIMARY KEY (`producer_id`),
KEY (`community_id`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_scalar` (
`scalar_id` bigint(20) NOT NULL AUTO_INCREMENT,
`trend_id` bigint(20) NOT NULL,
`value` double,
`producer_revision` varchar(255),
`submit_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user_id` bigint(20) NOT NULL DEFAULT '-1',
`submission_id` bigint(20) NOT NULL DEFAULT '-1',
`official` tinyint(4) NOT NULL DEFAULT '1',
`build_results_url` text NOT NULL,
`branch` varchar(255) NOT NULL DEFAULT '',
`extra_urls` text,
`reproduction_command` text,
PRIMARY KEY (`scalar_id`),
KEY (`trend_id`),
KEY (`submit_time`),
KEY (`user_id`),
KEY (`submission_id`),
KEY (`branch`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_submission` (
`submission_id` bigint(20) NOT NULL AUTO_INCREMENT,
`producer_id` bigint(20) NOT NULL,
`name` varchar(255) NOT NULL DEFAULT '',
`uuid` varchar(255) NOT NULL DEFAULT '',
`submit_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`submission_id`),
UNIQUE KEY (`uuid`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_scalar2item` (
`scalar_id` bigint(20) NOT NULL,
`item_id` bigint(20) NOT NULL,
`label` varchar(255) NOT NULL,
KEY (`scalar_id`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_threshold_notification` (
`threshold_id` bigint(20) NOT NULL AUTO_INCREMENT,
`trend_id` bigint(20) NOT NULL,
`value` double,
`comparison` varchar(2),
`action` varchar(80) NOT NULL,
`recipient_id` bigint(20) NOT NULL,
PRIMARY KEY (`threshold_id`),
KEY (`trend_id`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_trend` (
`trend_id` bigint(20) NOT NULL AUTO_INCREMENT,
`producer_id` bigint(20) NOT NULL,
`metric_name` varchar(255) NOT NULL,
`display_name` varchar(255) NOT NULL,
`unit` varchar(255) NOT NULL,
`config_item_id` bigint(20),
`test_dataset_id` bigint(20),
`truth_dataset_id` bigint(20),
`key_metric` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`trend_id`),
KEY (`producer_id`)
) DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `tracker_param` (
`param_id` bigint(20) NOT NULL AUTO_INCREMENT,
`scalar_id` bigint(20) NOT NULL,
`param_name` varchar(255) NOT NULL,
`param_type` enum('text', 'numeric') NOT NULL,
`text_value` text,
`numeric_value` double,
PRIMARY KEY (`param_id`),
KEY (`param_name`)
) DEFAULT CHARSET=utf8;
93 changes: 93 additions & 0 deletions modules/tracker/database/pgsql/1.2.3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
-- Midas Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- PostgreSQL database for the tracker module, version 1.2.2

SET client_encoding = 'UTF8';
SET default_with_oids = FALSE;

CREATE TABLE IF NOT EXISTS "tracker_producer" (
"producer_id" serial PRIMARY KEY,
"community_id" bigint NOT NULL,
"repository" character varying(255) NOT NULL,
"executable_name" character varying(255) NOT NULL,
"display_name" character varying(255) NOT NULL,
"description" text NOT NULL,
"revision_url" text NOT NULL
);

CREATE INDEX "tracker_producer_community_id" ON "tracker_producer" ("community_id");

CREATE TABLE IF NOT EXISTS "tracker_scalar" (
"scalar_id" serial PRIMARY KEY,
"trend_id" bigint NOT NULL,
"value" double precision,
"producer_revision" character varying(255),
"submit_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"user_id" bigint NOT NULL DEFAULT -1::bigint,
"submission_id" bigint NOT NULL DEFAULT -1::bigint,
"official" smallint NOT NULL DEFAULT 1::smallint,
"build_results_url" text NOT NULL,
"branch" character varying(255) NOT NULL DEFAULT ''::character varying,
"extra_urls" text,
"reproduction_command" text
);

CREATE INDEX "tracker_scalar_trend_id" ON "tracker_scalar" ("trend_id");
CREATE INDEX "tracker_scalar_submit_time" ON "tracker_scalar" ("submit_time");
CREATE INDEX "tracker_scalar_idx_branch" ON "tracker_scalar" ("branch");
CREATE INDEX "tracker_scalar_idx_user_id" ON "tracker_scalar" ("user_id");

CREATE TABLE IF NOT EXISTS "tracker_submission" (
"submission_id" serial PRIMARY KEY,
"producer_id" bigint,
"name" character varying(255) NOT NULL DEFAULT ''::character varying,
"uuid" character varying(255) NOT NULL DEFAULT ''::character varying,
"submit_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX "tracker_submission_uuid" ON "tracker_submission" ("uuid");
CREATE INDEX "tracker_submission_submit_time" ON "tracker_submission" ("submit_time");

CREATE TABLE IF NOT EXISTS "tracker_scalar2item" (
"id" serial PRIMARY KEY,
"scalar_id" bigint NOT NULL,
"item_id" bigint NOT NULL,
"label" character varying(255) NOT NULL
);

CREATE INDEX "tracker_scalar2item_scalar_id" ON "tracker_scalar2item" ("scalar_id");

CREATE TABLE IF NOT EXISTS "tracker_threshold_notification" (
"threshold_id" serial PRIMARY KEY,
"trend_id" bigint NOT NULL,
"value" double precision,
"comparison" character varying(2),
"action" character varying(80) NOT NULL,
"recipient_id" bigint NOT NULL
);

CREATE INDEX "tracker_threshold_notification_trend_id" ON "tracker_threshold_notification" ("trend_id");

CREATE TABLE IF NOT EXISTS "tracker_trend" (
"trend_id" serial PRIMARY KEY,
"producer_id" bigint NOT NULL,
"metric_name" character varying(255) NOT NULL,
"display_name" character varying(255) NOT NULL,
"unit" character varying(255) NOT NULL,
"config_item_id" bigint,
"test_dataset_id" bigint,
"truth_dataset_id" bigint,
"key_metric" smallint NOT NULL DEFAULT 0::smallint
);

CREATE INDEX "tracker_trend_producer_id" ON "tracker_trend" ("producer_id");

CREATE TABLE IF NOT EXISTS "tracker_param" (
"param_id" serial PRIMARY KEY,
"scalar_id" bigint NOT NULL,
"param_name" character varying(255) NOT NULL,
"param_type" text CHECK (param_type IN ('text', 'numeric')),
"text_value" text,
"numeric_value" double precision);
);

CREATE INDEX "tracker_param_param_name_idx" ON "tracker_param" ("param_name");
91 changes: 91 additions & 0 deletions modules/tracker/database/sqlite/1.2.3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
-- Midas Server. Copyright Kitware SAS. Licensed under the Apache License 2.0.

-- SQLite database for the tracker module, version 1.2.2

CREATE TABLE IF NOT EXISTS "tracker_producer" (
"producer_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"community_id" INTEGER NOT NULL,
"repository" TEXT NOT NULL,
"executable_name" TEXT NOT NULL,
"display_name" TEXT NOT NULL,
"description" TEXT NOT NULL,
"revision_url" TEXT NOT NULL
);

CREATE INDEX IF NOT EXISTS "tracker_producer_community_id_idx" ON "tracker_producer" ("community_id");

CREATE TABLE IF NOT EXISTS "tracker_scalar" (
"scalar_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"trend_id" INTEGER NOT NULL,
"value" REAL,
"producer_revision" TEXT,
"submit_time" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
"user_id" INTEGER NOT NULL DEFAULT -1,
"submission_id" INTEGER NOT NULL DEFAULT -1,
"official" INTEGER NOT NULL DEFAULT 1,
"build_results_url" TEXT NOT NULL,
"branch" TEXT NOT NULL DEFAULT '',
"extra_urls" TEXT,
"reproduction_command" TEXT
);

CREATE INDEX IF NOT EXISTS "tracker_scalar_trend_id_idx" ON "tracker_scalar" ("trend_id");
CREATE INDEX IF NOT EXISTS "tracker_scalar_submit_time_idx" ON "tracker_scalar" ("submit_time");
CREATE INDEX IF NOT EXISTS "tracker_scalar_branch_idx" ON "tracker_scalar" ("branch");
CREATE INDEX IF NOT EXISTS "tracker_scalar_user_id_idx" ON "tracker_scalar" ("user_id");


CREATE TABLE IF NOT EXISTS "tracker_submission" (
"submission_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"producer_id" INTEGER NOT NULL,
"name" TEXT NOT NULL DEFAULT '',
"uuid" TEXT NOT NULL DEFAULT '',
"submit_time" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX IF NOT EXISTS "tracker_submission_uuid_idx" ON "tracker_submission" ("uuid");
CREATE INDEX IF NOT EXISTS "tracker_submission_submit_time_idx" ON "tracker_submission" ("submit_time");


CREATE TABLE IF NOT EXISTS "tracker_scalar2item" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"scalar_id" INTEGER NOT NULL,
"item_id" INTEGER NOT NULL,
"label" TEXT NOT NULL
);

CREATE INDEX IF NOT EXISTS "tracker_scalar2item_scalar_id_idx" ON "tracker_scalar2item" ("scalar_id");

CREATE TABLE IF NOT EXISTS "tracker_threshold_notification" (
"threshold_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"trend_id" INTEGER NOT NULL,
"value" REAL,
"comparison" TEXT,
"action" TEXT NOT NULL,
"recipient_id" INTEGER NOT NULL
);

CREATE INDEX IF NOT EXISTS "tracker_threshold_notification_trend_id_idx" ON "tracker_threshold_notification" ("trend_id");

CREATE TABLE IF NOT EXISTS "tracker_trend" (
"trend_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"producer_id" INTEGER NOT NULL,
"metric_name" TEXT NOT NULL,
"display_name" TEXT NOT NULL,
"unit" TEXT NOT NULL,
"config_item_id" INTEGER,
"test_dataset_id" INTEGER,
"truth_dataset_id" INTEGER,
"key_metric" INTEGER NOT NULL DEFAULT 0
);

CREATE INDEX IF NOT EXISTS "tracker_trend_producer_id_idx" ON "tracker_trend" ("producer_id");

CREATE TABLE IF NOT EXISTS "tracker_param" (
"param_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"scalar_id" INTEGER NOT NULL,
"param_name" TEXT NOT NULL,
"param_type" TEXT CHECK( param_type in ('text', 'numeric') ) NOT NULL,
"text_value" text,
"numeric_value" REAL
);
CREATE INDEX IF NOT EXISTS "tracker_param_param_name" ON "tracker_param" ("param_name");
35 changes: 35 additions & 0 deletions modules/tracker/database/upgrade/1.2.3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/*=========================================================================
Midas Server
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France.
All rights reserved.
For more information visit http://www.kitware.com/.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

/** Upgrade the tracker module to version 1.2.3. */
class Tracker_Upgrade_1_2_3 extends MIDASUpgrade
{
/** Upgrade a MySQL database. */
public function mysql()
{
$this->db->query('ALTER TABLE `tracker_scalar` ADD COLUMN `reproduction_command` text;');
}

/** Upgrade a PostgreSQL database. */
public function pgsql()
{
$this->db->query('ALTER TABLE tracker_scalar ADD COLUMN reproduction_command text;');
}
}
6 changes: 5 additions & 1 deletion modules/tracker/models/base/ScalarModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function __construct()
'submit_time' => array('type' => MIDAS_DATA),
'value' => array('type' => MIDAS_DATA),
'producer_revision' => array('type' => MIDAS_DATA),
'reproduction_command' => array('type' => MIDAS_DATA),
'trend' => array(
'type' => MIDAS_MANY_TO_ONE,
'model' => 'Trend',
Expand Down Expand Up @@ -137,6 +138,7 @@ abstract public function getDistinctBranches();
* @param null|string $branch branch name
* @param null|string|array $params parameters
* @param null|string|array $extraUrls extra URLs
* @param null|string $reproductionCommand the command to reproduce this run
* @return Tracker_ScalarDao scalar DAO
*/
public function addToTrend(
Expand All @@ -151,7 +153,8 @@ public function addToTrend(
$buildResultsUrl = '',
$branch = '',
$params = null,
$extraUrls = null
$extraUrls = null,
$reproductionCommand = null
) {
if ($overwrite === true) {
$scalarDao = $this->getByTrendAndTimestamp($trendDao->getKey(), $submitTime, $userDao->getKey());
Expand Down Expand Up @@ -181,6 +184,7 @@ public function addToTrend(
$scalarDao->setBuildResultsUrl($buildResultsUrl);
$scalarDao->setBranch(trim($branch));
$scalarDao->setExtraUrls($extraUrls);
$scalarDao->setReproductionCommand($reproductionCommand);
$this->save($scalarDao);

if (!empty($params) && is_array($params)) {
Expand Down
2 changes: 2 additions & 0 deletions modules/tracker/models/dao/ScalarDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
* @method void setTrend(Tracker_TrendDao $trendDao)
* @method UserDao getUser()
* @method void setUser(UserDao $userDao)
* @method string getReproductionCommand()
* @method void setReproductionCommand(string $reproductionCommand)
*/
class Tracker_ScalarDao extends Tracker_AppDao
{
Expand Down

0 comments on commit 3783a6d

Please sign in to comment.