IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25423


Ignore:
Timestamp:
Sep 16, 2009, 5:05:19 PM (17 years ago)
Author:
bills
Message:

added new magicDSRun.states goto_restored and goto_censored
The 'revert' process handles processing these transitions
the end result is either 'restored' or 'cesored'
Removed torestoreMode which wasn't implemented yet

Location:
trunk
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/magic_destreak_revert.pl

    r25383 r25423  
    191191}
    192192
    193 revert_files($image, $mask, $weight, $sources, $astrom, $bimage, $bmask, $bweight, $bsources, $bastrom);
     193revert_files($replace, $image, $mask, $weight, $sources, $astrom, $bimage, $bmask, $bweight, $bsources, $bastrom);
    194194
    195195if ($stage eq "diff") {
     
    203203    $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base);
    204204    $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base);
    205     revert_files($image, $mask, $weight, $sources, undef, $bimage, $bmask, $bweight, $bsources, undef);
     205    revert_files($replace, $image, $mask, $weight, $sources, undef, $bimage, $bmask, $bweight, $bsources, undef);
    206206}
    207207
    208208# now revert the row in the database
    209209{
    210     my $command = "$magicdstool -revertdestreakedfile";
     210    my $command = "$magicdstool -revertdestreakedfile -i_am_sure";
    211211    $command   .= " -magic_ds_id $magic_ds_id";
    212212    $command   .= " -component $component";
     
    231231
    232232sub revert_files {
     233    my $replace = shift;
     234    return if !$replace;
     235
    233236    my $image = shift;
    234237    my $mask = shift;
  • trunk/ippTasks/destreak.pro

    r25419 r25423  
    1111book init magicDSToRevert
    1212
    13 ### Database lists
     13### indexes into Database lists
    1414$magicToDS_DB = 0
    1515$magicDSToRevert_DB = 0
     16$magicDSCompletedRevert_DB = 0
    1617
    1718#list of stages
     
    2829### Check status of tasks
    2930macro magic.status
    30   book listbook magicToDS
    31   book listbook magicDSToRevert
     31    book listbook magicToDS
     32    book listbook magicDSToRevert
    3233end
    3334
    3435### Reset tasks
    3536macro magic.reset
    36   book init magicToDS
    37   book init magicDSToRevert
     37    book init magicToDS
     38    book init magicDSToRevert
    3839end
    3940
    4041### Turn tasks on
    4142macro destreak.on
    42   task destreak.load
    43     active true
    44   end
    45   task destreak.run
    46     active true
    47   end
     43    task destreak.load
     44        active true
     45    end
     46    task destreak.run
     47        active true
     48    end
    4849end
    4950
     
    5556        active true
    5657    end
    57 end
     58    task destreak.completed.revert
     59        active true
     60    end
     61end
     62
    5863### Turn tasks off
    5964macro destreak.off
    60   task destreak.load
    61     active false
    62   end
    63   task destreak.run
    64     active false
    65   end
     65    task destreak.load
     66        active false
     67    end
     68    task destreak.run
     69        active false
     70    end
    6671end
    6772
     
    7176    end
    7277    task destreak.revert.run
     78        active false
     79    end
     80    task destreak.completed.revert
    7381        active false
    7482    end
     
    363371
    364372task           destreak.completed.revert
     373    # task to finish processing for magicDSRuns being reverted or restored
    365374  host         local
    366375
    367376  periods      -poll $LOADPOLL
    368   periods      -exec $LOADEXEC
     377  #periods      -exec $LOADEXEC
     378  periods      -exec 30
    369379  periods      -timeout 20
    370380  npending     1
     
    380390    else
    381391      # save the DB name for the exit tasks
    382       option $DB:$magicDSToRevert_DB
    383       $run = $run -dbname $DB:$magicDSToRevert_DB
     392      option $DB:$magicDSCompletedRevert_DB
     393
     394      $run = $run -dbname $DB:$magicDSCompletedRevert_DB
     395
     396      if ($magicDSCompletedRevert_DB >= $DB:n) set magicDSCompletedRevert_DB = 0
    384397    end
    385398    add_poll_args run
     
    390403  # success
    391404  task.exit    0
    392     # convert 'stdout' to book format
    393     ipptool2book stdout magicDSToRevert -key magic_ds_id:component -uniq -setword dbname $options:0 -setword pantaskState INIT
    394     if ($VERBOSE > 2)
    395       book listbook magicDSToRevert
    396     end
    397 
    398     # delete existing entries in the appropriate pantaskStates
    399     process_cleanup magicDSToRevert
    400405  end
    401406
  • trunk/ippTools/share/Makefile.am

    r25419 r25423  
    173173     magicdstool_getrunids.sql \
    174174     magicdstool_getskycells.sql \
     175     magicdstool_revertdestreakedfile.sql \
    175176     magicdstool_todestreak_camera.sql \
    176177     magicdstool_todestreak_chip.sql \
     
    179180     magicdstool_todestreak_warp.sql \
    180181     magicdstool_toremove.sql \
    181      magicdstool_torestore.sql \
    182182     magicdstool_torevert_raw.sql \
    183183     magicdstool_torevert_chip.sql \
  • trunk/ippTools/share/magicdstool_torevert_camera.sql

    r25419 r25423  
    11SELECT
    22    magic_ds_id,
     3    magicDSRun.state,
    34    exp_id,
    45    re_place,
     
    2021WHERE magicDSRun.stage = 'camera'
    2122    AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0)
    22        OR magicDSRun.state = 'goto_censored'
    23        OR magicDSRun.state = 'goto_restored')
     23         OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored')
     24              AND (backup_path_base IS NOT NULL)
     25            )
     26        )
  • trunk/ippTools/share/magicdstool_torevert_chip.sql

    r25419 r25423  
    11SELECT
    22    magic_ds_id,
     3    magicDSRun.state,
    34    exp_id,
    45    re_place,
     
    1920WHERE magicDSRun.stage = 'chip'
    2021    AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0)
    21        OR magicDSRun.state = 'goto_censored'
    22        OR magicDSRun.state = 'goto_restored')
     22         OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored')
     23              AND ((backup_path_base IS NOT NULL) OR (recovery_path_base IS NOT NULL))
     24            )
     25        )
  • trunk/ippTools/share/magicdstool_torevert_diff.sql

    r25419 r25423  
    11SELECT
    22    magic_ds_id,
     3    magicDSRun.state,
    34    exp_id,
    45    re_place,
     
    1920WHERE magicDSRun.stage = 'diff'
    2021    AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0)
    21        OR magicDSRun.state = 'goto_censored'
    22        OR magicDSRun.state = 'goto_restored')
     22         OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored')
     23              AND ((backup_path_base IS NOT NULL) OR (recovery_path_base IS NOT NULL))
     24            )
     25        )
  • trunk/ippTools/share/magicdstool_torevert_raw.sql

    r25419 r25423  
    11SELECT
    22    magic_ds_id,
     3    magicDSRun.state,
    34    exp_id,
    45    re_place,
     
    1516    JOIN magicDSFile using(magic_ds_id)
    1617    JOIN rawImfile ON (stage_id = exp_id AND component = class_id)
    17     JOIN summitImfile ON (rawImfile.exp_name = summitImfile.exp_name
    18                       AND rawImfile.tmp_class_id = summitImfile.class_id)
    1918WHERE magicDSRun.stage = 'raw'
    2019    AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0)
    21        OR magicDSRun.state = 'goto_censored'
    22        OR magicDSRun.state = 'goto_restored')
     20         OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored')
     21              AND ((backup_path_base IS NOT NULL) OR (recovery_path_base IS NOT NULL))
     22            )
     23        )
  • trunk/ippTools/share/magicdstool_torevert_warp.sql

    r25419 r25423  
    11SELECT
    22    magic_ds_id,
     3    magicDSRun.state,
    34    exp_id,
    45    re_place,
     
    2223WHERE magicDSRun.stage = 'warp'
    2324    AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0)
    24        OR magicDSRun.state = 'goto_censored'
    25        OR magicDSRun.state = 'goto_restored')
     25         OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored')
     26              AND ((backup_path_base IS NOT NULL) OR (recovery_path_base IS NOT NULL))
     27            )
     28        )
  • trunk/ippTools/src/magicdstool.c

    r25419 r25423  
    4040static bool getskycellsMode(pxConfig *config);
    4141static bool toremoveMode(pxConfig *config);
    42 static bool torestoreMode(pxConfig *config);
    4342static bool torevertMode(pxConfig *config);
    4443static bool completedrevertMode(pxConfig *config);
     
    7473        MODECASE(MAGICDSTOOL_MODE_GETSKYCELLS,         getskycellsMode);
    7574        MODECASE(MAGICDSTOOL_MODE_TOREMOVE,            toremoveMode);
    76         MODECASE(MAGICDSTOOL_MODE_TORESTORE,           torestoreMode);
    7775        MODECASE(MAGICDSTOOL_MODE_TOREVERT,            torevertMode);
    7876        MODECASE(MAGICDSTOOL_MODE_COMPLETEDREVERT,     completedrevertMode);
     
    401399
    402400    psMetadata *where = psMetadataAlloc();
    403     PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "==");
     401    PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magicDSRun.magic_ds_id", "==");
    404402    PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
    405403    pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "==");
     
    803801    PS_ASSERT_PTR_NON_NULL(config, false);
    804802
     803    PXOPT_LOOKUP_BOOL(i_am_sure, config->args, "-i_am_sure", true);
     804    if (!i_am_sure) {
     805        psError(PS_ERR_UNKNOWN, true, "Reverting destreaked files must be done carefully. -i_am_sure is required.");
     806        return false;
     807    }
     808
    805809    psMetadata *where = psMetadataAlloc();
    806810    PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magicDSRun.magic_ds_id", "==");
     
    809813    pxAddLabelSearchArgs (config, where, "-label", "label", "==");
    810814
    811     psString query = psStringCopy("DELETE FROM magicDSFile USING magicDSFile, magicDSRun  WHERE (magicDSRun.magic_ds_id = magicDSFile.magic_ds_id) AND magicDSFile.fault != 0");
     815    psString query = pxDataGet("magicdstool_revertdestreakedfile.sql");
    812816
    813817    if (psListLength(where->list)) {
     
    815819        psStringAppend(&query, " AND %s", whereClause);
    816820        psFree(whereClause);
     821    } else {
     822        psError(PS_ERR_UNKNOWN, true, "search arguments are required");
     823        return false;
    817824    }
    818825    psFree(where);
     
    820827    if (!p_psDBRunQuery(config->dbh, query)) {
    821828        psError(PS_ERR_UNKNOWN, false, "failed to revert");
    822         return false;
    823     }
     829        psFree(query);
     830        return false;
     831    }
     832    psFree(query);
    824833    return true;
    825834}
     
    891900        }
    892901        char *query2 = "UPDATE magicDSRun SET state = '%s' WHERE magic_ds_id = %" PRId64;
    893         if (!p_psDBRunQueryF(config->dbh, query2, magic_ds_id, new_state)) {
     902        if (!p_psDBRunQueryF(config->dbh, query2, new_state, magic_ds_id)) {
    894903            psError(PS_ERR_UNKNOWN, false, "failed to set run magicDSRun.state to %s", new_state);
    895904            return false;
     
    971980
    972981    // check that state is a valid string value
    973     if (!(
    974             (strncmp(state, "new", 4) == 0)
    975             || (strncmp(state, "full", 5) == 0)
    976         )
    977     ) {
     982    if (!((strcmp(state, "new") == 0) ||
     983          (strcmp(state, "full") == 0) ||
     984          (strcmp(state, "restored") == 0) ||
     985          (strcmp(state, "censored") == 0) ||
     986          (strcmp(state, "purged") == 0) ||
     987          (strcmp(state, "goto_restored") == 0) ||
     988          (strcmp(state, "goto_censored") == 0) ||
     989          (strcmp(state, "goto_purged") == 0))
     990        ) {
    978991        psError(PS_ERR_UNKNOWN, false,
    979992                "invalid magicDSRun state: %s", state);
     
    10641077    return true;
    10651078}
    1066 static bool torestoreMode(pxConfig *config)
     1079
     1080static bool torevertMode(pxConfig *config)
    10671081{
    10681082    PS_ASSERT_PTR_NON_NULL(config, false);
    10691083
    10701084    psMetadata *where = psMetadataAlloc();
     1085    PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false);
     1086
    10711087    PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "==");
    10721088    PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
    1073     pxAddLabelSearchArgs (config, where, "-label", "label", "==");
     1089    pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "==");
    10741090
    10751091    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    10761092    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    10771093
    1078     // look for "inputs" that need to processed
    1079     psString query = pxDataGet("magicdstool_torestore.sql");
     1094    psString sql_file = NULL;
     1095    psStringAppend(&sql_file, "magicdstool_torevert_%s.sql", stage);
     1096
     1097    psString query = pxDataGet(sql_file);
    10801098    if (!query) {
    1081         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    1082         return false;
    1083     }
     1099        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement from %s", sql_file);
     1100        psFree(sql_file);
     1101        return false;
     1102    }
     1103    psFree(sql_file);
    10841104
    10851105    if (psListLength(where->list)) {
    10861106        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    1087         psStringAppend(&query, " WHERE %s", whereClause);
     1107        psStringAppend(&query, " AND %s", whereClause);
    10881108        psFree(whereClause);
    10891109    }
     
    11261146    if (psArrayLength(output)) {
    11271147        // negative simple so the default is true
    1128         if (!ippdbPrintMetadatas(stdout, output, "torestore", !simple)) {
    1129             psError(PS_ERR_UNKNOWN, false, "failed to print array");
    1130             psFree(output);
    1131             return false;
    1132         }
    1133     }
    1134 
    1135     psFree(output);
    1136 
    1137     return true;
    1138 }
    1139 
    1140 
    1141 static bool torevertMode(pxConfig *config)
    1142 {
    1143     PS_ASSERT_PTR_NON_NULL(config, false);
    1144 
    1145     psMetadata *where = psMetadataAlloc();
    1146     PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false);
    1147 
    1148     PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "==");
    1149     PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
    1150     pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "==");
    1151 
    1152     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    1153     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    1154 
    1155     psString sql_file = NULL;
    1156     psStringAppend(&sql_file, "magicdstool_torevert_%s.sql", stage);
    1157 
    1158     psString query = pxDataGet(sql_file);
    1159     if (!query) {
    1160         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement from %s", sql_file);
    1161         psFree(sql_file);
    1162         return false;
    1163     }
    1164     psFree(sql_file);
    1165 
    1166     if (psListLength(where->list)) {
    1167         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    1168         psStringAppend(&query, " AND %s", whereClause);
    1169         psFree(whereClause);
    1170     }
    1171     psFree(where);
    1172 
    1173     // treat limit == 0 as "no limit"
    1174     if (limit) {
    1175         psString limitString = psDBGenerateLimitSQL(limit);
    1176         psStringAppend(&query, " %s", limitString);
    1177         psFree(limitString);
    1178     }
    1179 
    1180     if (!p_psDBRunQuery(config->dbh, query)) {
    1181         psError(PS_ERR_UNKNOWN, false, "database error");
    1182         psFree(query);
    1183         return false;
    1184     }
    1185     psFree(query);
    1186 
    1187     psArray *output = p_psDBFetchResult(config->dbh);
    1188     if (!output) {
    1189         psErrorCode err = psErrorCodeLast();
    1190         switch (err) {
    1191             case PS_ERR_DB_CLIENT:
    1192                 psError(PXTOOLS_ERR_SYS, false, "database error");
    1193             case PS_ERR_DB_SERVER:
    1194                 psError(PXTOOLS_ERR_PROG, false, "database error");
    1195             default:
    1196                 psError(PXTOOLS_ERR_PROG, false, "unknown error");
    1197         }
    1198 
    1199         return false;
    1200     }
    1201     if (!psArrayLength(output)) {
    1202         psTrace("magicdstool", PS_LOG_INFO, "no rows found");
    1203         psFree(output);
    1204         return true;
    1205     }
    1206 
    1207     if (psArrayLength(output)) {
    1208         // negative simple so the default is true
    12091148        if (!ippdbPrintMetadatas(stdout, output, "torevert", !simple)) {
    12101149            psError(PS_ERR_UNKNOWN, false, "failed to print array");
  • trunk/ippTools/src/magicdstool.h

    r25419 r25423  
    3333    MAGICDSTOOL_MODE_GETSKYCELLS,
    3434    MAGICDSTOOL_MODE_TOREMOVE,
    35     MAGICDSTOOL_MODE_TORESTORE,
    3635    MAGICDSTOOL_MODE_TOREVERT,
    3736    MAGICDSTOOL_MODE_COMPLETEDREVERT,
  • trunk/ippTools/src/magicdstoolConfig.c

    r25419 r25423  
    114114    psMetadataAddStr(revertdestreakedfileArgs, PS_LIST_TAIL, "-component", 0, "search by component", NULL);
    115115    psMetadataAddS16(revertdestreakedfileArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0);
     116    psMetadataAddBool(revertdestreakedfileArgs, PS_LIST_TAIL, "-i_am_sure", 0, "confirm that you know what you are doing", false);
    116117    psMetadataAddStr(revertdestreakedfileArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "define label", NULL);
    117118
    118119    // -getskycells
    119120    psMetadata *getskycellsArgs = psMetadataAlloc();
    120     psMetadataAddS64(getskycellsArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magic de-streak ID (required)", 0);
     121    psMetadataAddS64(getskycellsArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magic de-streak ID", 0);
    121122    psMetadataAddStr(getskycellsArgs, PS_LIST_TAIL, "-class_id", 0, "define class identifier", NULL);
    122123    psMetadataAddStr(getskycellsArgs, PS_LIST_TAIL, "-skycell_id", 0, "define skycell identifier", NULL);
     
    130131    psMetadataAddU64(toremoveArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);
    131132    psMetadataAddBool(toremoveArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
    132 
    133     // -torestore
    134     psMetadata *torestoreArgs = psMetadataAlloc();
    135     psMetadataAddS64(torestoreArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magic Destreak ID", 0);
    136     psMetadataAddS64(torestoreArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magic ID", 0);
    137     psMetadataAddStr(torestoreArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "define label", NULL);
    138     psMetadataAddU64(torestoreArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);
    139     psMetadataAddBool(torestoreArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
    140133
    141134    // -torevert
     
    175168    PXOPT_ADD_MODE("-toremove", "backup images pending removal",
    176169                    MAGICDSTOOL_MODE_TOREMOVE, toremoveArgs);
    177     PXOPT_ADD_MODE("-torestore", "images pending restore of exicsed streak pixels",
    178                     MAGICDSTOOL_MODE_TORESTORE, torestoreArgs);
    179     PXOPT_ADD_MODE("-torevert", "faulted images to revert",
     170    PXOPT_ADD_MODE("-torevert", "images to restore or revert",
    180171                    MAGICDSTOOL_MODE_TOREVERT, torevertArgs);
    181172
Note: See TracChangeset for help on using the changeset viewer.