IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33301


Ignore:
Timestamp:
Feb 17, 2012, 6:20:27 AM (14 years ago)
Author:
eugene
Message:

add ohana version of realpath, fix rconnect version of relphot, update testing

Location:
branches/eam_branches/ipp-20111122/Ohana/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/addstar/test/relphot.parallel.dvo

    r33297 r33301  
    132132
    133133  # run relphot on the parallel db and check that the images now match the expected values
    134   exec relphot -parallel-serial g,r,i -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir.p0 -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -keep-ubercal -D IMAGE_OFFSET 0.5 -update >& log.relphot.p0
    135 
    136   exec dvodist -in $catdir.p0
     134  exec relphot -parallel g,r,i -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir.p0 -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -keep-ubercal -D IMAGE_OFFSET 0.5 -update >& log.relphot.p0
     135
     136  exec dvodist -in $catdir.p0 >& log.dvodist.in
    137137
    138138  for i 0 mjd_nc[]
     
    432432  $catdir = $tmp1/$tmp2
    433433
    434   exec rsync -auv $catdir/ $catdir.p0/
     434  exec rsync -auv $catdir/ $catdir.p0/ >& log.rsync
    435435  mkdir $catdir.d1
    436436  mkdir $catdir.d2
     
    442442  exec echo "3 $hostname $catdir.d3" >> $catdir.p0/HostTable.dat
    443443
    444   exec dvodist -out $catdir.p0
    445 end
    446 
     444  exec dvodist -out $catdir.p0 >& log.dvodist.out
     445end
     446
  • branches/eam_branches/ipp-20111122/Ohana/src/libohana/include/ohana.h

    r33238 r33301  
    264264int     check_dir_access       PROTO((char *path, int verbose));
    265265int     check_file_exec        PROTO((char *filename));
     266char   *abspath                PROTO((char *oldpath, int maxlength));
    266267
    267268/* in glockfile.c */
  • branches/eam_branches/ipp-20111122/Ohana/src/libohana/src/findexec.c

    r27435 r33301  
    404404  return TRUE;
    405405}
     406
     407// ohana-based equivalent to 'realpath'.  realpath does not guarantee an absolute path (eg on Solaris),
     408// just a 'cannonical path'.  I don't care about resolving out links, just ensuring an absolute path
     409// also, realpath is a bit ambiguous on the maxlength argument
     410char *abspath (char *oldpath, int maxlength) {
     411
     412  if (!oldpath) return NULL;
     413
     414  if (oldpath[0] == '/') {
     415    char *newpath = strcreate (oldpath);
     416    return newpath;
     417  }
     418
     419  char *cwd  = getcwd(NULL, maxlength);
     420  if (cwd == NULL) {
     421    // XXX need an error reporting function...
     422    fprintf (stderr, "error getting cwd (longer than %d chars?)\n", maxlength);
     423    return NULL;
     424  }
     425
     426  char *newpath = NULL;
     427
     428  int Nbytes = strlen(cwd) + strlen(oldpath) + 2;
     429  ALLOCATE (newpath, char, Nbytes);
     430  snprintf (newpath, Nbytes, "%s/%s", cwd, oldpath);
     431  return newpath;
     432}
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/include/relphot.h

    r33298 r33301  
    7171
    7272/* global variables set in parameter file */
    73 char   ImageCat[256];
    74 char   ImageTemplate[256];
    75 char   CatTemplate[256];
    76 char   GSCFILE[256];
    77 char   CATDIR[256];
     73# define MAX_PATH_LENGTH 1024
     74char   ImageCat[MAX_PATH_LENGTH];
     75char   ImageTemplate[MAX_PATH_LENGTH];
     76char   CatTemplate[MAX_PATH_LENGTH];
     77char   GSCFILE[MAX_PATH_LENGTH];
     78char  *CATDIR;
    7879char   CATMODE[16];    /* raw, mef, split, mysql */
    7980char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
    80 char   CameraConfig[256];
    81 char   SKY_TABLE[256];
     81char   CameraConfig[MAX_PATH_LENGTH];
     82char   SKY_TABLE[MAX_PATH_LENGTH];
    8283int    SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
    8384
     
    314315int CopyMeasureTiny (MeasureTiny *measureT, Measure *measure);
    315316
     317int HostTableWaitJobs (HostTable *table, char *file, int lineno);
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/ConfigInit.c

    r30616 r33301  
    3333  GetConfig (config, "IMAGE_GOOD_FRACTION",    "%lf", 0, &IMAGE_GOOD_FRACTION);
    3434
     35  // force CATDIR to be absolute (so parallel mode will work)
     36  char *tmpcatdir = NULL;
     37  ALLOCATE (tmpcatdir, char, MAX_PATH_LENGTH);
     38  GetConfig (config, "CATDIR",                 "%s",  0, tmpcatdir);
     39  CATDIR = abspath (tmpcatdir, MAX_PATH_LENGTH);
     40  free (tmpcatdir);
     41
    3542  GetConfig (config, "GSCFILE",                "%s",  0, GSCFILE);
    36   GetConfig (config, "CATDIR",                 "%s",  0, CATDIR);
    3743  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    3844  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_catalogs.c

    r33300 r33301  
    108108  }   
    109109
    110   char *cwd;
    111   if ((cwd = getcwd(NULL, 1024)) == NULL) {
    112     fprintf (stderr, "error getting cwd (longer than 1024 chars?)\n");
    113     exit (1);
    114   }
    115 
    116110  int i;
    117111  for (i = 0; i < table->Nhosts; i++) {
    118112
    119     // if table->hosts[i].pathname is a relative path (pathname[0] is not '/'), then
    120     // we need to prepend our current path
    121 
    122     if (table->hosts[i].pathname[0] != '/') {
    123       int Nbytes = strlen(cwd) + strlen(table->hosts[i].pathname) + 2;
    124       char *newpath = NULL;
    125       ALLOCATE (newpath, char, Nbytes);
    126       snprintf (newpath, Nbytes, "%s/%s", cwd, table->hosts[i].pathname);
    127       free (table->hosts[i].pathname);
    128       table->hosts[i].pathname = newpath;
    129     }
     113    // ensure that the paths are absolute path names
     114    char *tmppath = abspath (table->hosts[i].pathname, MAX_PATH_LENGTH);
     115    free (table->hosts[i].pathname);
     116    table->hosts[i].pathname = tmppath;
    130117
    131118    char catalogFile[512];
     
    190177  }
    191178  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    192     // we have launched table->Nhosts jobs; wait for all of them to complete...
    193     for (i = 0; i < table->Nhosts; i++) {
    194       int status = 0;
    195       int pid = waitpid (-1, &status, 0);
    196 
    197       // XXX we'll need to pass in WNOHANG and keep retrying if we want to have a timeout...
    198       // find the host which has finished
    199       int j;
    200       for (j = 0; j < table->Nhosts; j++) {
    201         if (table->hosts[j].pid != pid) continue;
    202         // check on the status of this and report any output?
    203         fprintf (stderr, "job finished for %s (%d)\n", table->hosts[j].hostname, pid);
    204         if (WIFEXITED(status)) {
    205           fprintf (stderr, "normal completion, exit status is %d\n", WEXITSTATUS(status));
    206           if (WEXITSTATUS(status)) {
    207             fprintf (stderr, "job failed on %s\n", table->hosts[j].hostname);
    208           }
    209         }
    210         // read the stderr and stdout
    211         IOBuffer buffer;
    212         InitIOBuffer (&buffer, 100);
    213         EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[1]);
    214         fprintf (stderr, "--- stdout from %s ---\n", table->hosts[j].hostname);
    215         write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
    216         fprintf (stderr, "\n");
    217          
    218         InitIOBuffer (&buffer, 100);
    219         EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[2]);
    220         fprintf (stderr, "--- stderr from %s ---\n", table->hosts[j].hostname);
    221         write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
    222         fprintf (stderr, "\n");
    223       }
    224     }
     179    HostTableWaitJobs (table, __FILE__, __LINE__);
    225180  }
    226181
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/reload_catalogs.c

    r33298 r33301  
    11# include "relphot.h"
     2# include <sys/types.h>
     3# include <sys/wait.h>
    24
    35# define DEBUG 1
     
    132134  int i;
    133135  for (i = 0; i < table->Nhosts; i++) {
     136
     137    // ensure that the paths are absolute path names
     138    char *tmppath = abspath (table->hosts[i].pathname, MAX_PATH_LENGTH);
     139    free (table->hosts[i].pathname);
     140    table->hosts[i].pathname = tmppath;
    134141
    135142    char command[1024];
     
    179186      }
    180187      table->hosts[i].pid = pid; // save for future reference
    181       // check that all hosts started OK?
    182188    }
    183189  }
     
    186192    fprintf (stderr, "run the relphot_client commands above.  when these are done, hit return\n");
    187193    getchar();
    188   } else {
    189     // watch for stdout / stderr from those jobs...
    190     // wait for all of them to complete...
    191   }
    192 
     194  }
     195  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
     196    HostTableWaitJobs (table, __FILE__, __LINE__);
     197  }
    193198  return (TRUE);
    194199}     
     200
     201// wait for all children to complete, report output to stdout
     202int HostTableWaitJobs (HostTable *table, char *file, int lineno) {
     203
     204  int i;
     205
     206  // we have launched table->Nhosts jobs; wait for all of them to complete...
     207  // if one (N) failed to launch, we will get an ECHILD error from the last (N) calls
     208  int done = FALSE;
     209  for (i = 0; !done  && (i < table->Nhosts); i++) {
     210    int status = 0;
     211
     212    // XXX we'll need to pass in WNOHANG and keep retrying if we want to have a timeout...
     213    int pid = waitpid (-1, &status, 0);
     214    if (!pid) {
     215      // this should only occur if we called waitpid with the WNOHANG option
     216      fprintf (stderr, "programming error (1)? %s %d", file, lineno);
     217      exit (2);
     218    }
     219    if (pid == -1) {
     220      switch (errno) {
     221        case ECHILD:
     222          done = TRUE;
     223          break;
     224        default:
     225          fprintf (stderr, "programming error (2)? %s %d", file, lineno);
     226          exit (2);
     227      }
     228    }
     229
     230    // find the host which has finished
     231    int j;
     232    int found = FALSE;
     233    for (j = 0; j < table->Nhosts; j++) {
     234      if (table->hosts[j].pid != pid) continue;
     235      found = TRUE;
     236      // check on the status of this and report any output?
     237      fprintf (stderr, "job finished for %s (%d)\n", table->hosts[j].hostname, pid);
     238      // read the stderr and stdout
     239      IOBuffer buffer;
     240      InitIOBuffer (&buffer, 100);
     241      EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[1]);
     242      fprintf (stderr, "--- stdout from %s ---\n", table->hosts[j].hostname);
     243      write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
     244      fprintf (stderr, "\n");
     245         
     246      InitIOBuffer (&buffer, 100);
     247      EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[2]);
     248      fprintf (stderr, "--- stderr from %s ---\n", table->hosts[j].hostname);
     249      write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer);
     250      fprintf (stderr, "\n");
     251      if (WIFEXITED(status)) {
     252        fprintf (stderr, "normal completion, exit status is %d\n", WEXITSTATUS(status));
     253        if (WEXITSTATUS(status)) {
     254          fprintf (stderr, "job failed on %s\n", table->hosts[j].hostname);
     255          exit (1);
     256        }
     257      } else {
     258        fprintf (stderr, "job exited abnormally on %s\n", table->hosts[j].hostname);
     259        exit (1);
     260      }
     261    }
     262    if (!found) {
     263      fprintf (stderr, "failed to matched finished job to known host!\n");
     264      exit (2);
     265    }
     266  }
     267  return TRUE;
     268}
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/relphot_client.c

    r33254 r33301  
    2222  // load the current sky table (layout of all SkyRegions)
    2323  SkyTable *sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, -1, VERBOSE);
     24  if (!sky) {
     25      fprintf (stderr, "ERROR running loading sky table from %s\n", CATDIR);
     26      exit (2);
     27  }
    2428  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2529
    2630  SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
     31  if (!skylist) {
     32      fprintf (stderr, "ERROR setting up skylist for %s\n", CATDIR);
     33      exit (2);
     34  }
    2735 
    2836  switch (MODE) {
     
    3038      int Ncatalog;
    3139      Catalog *catalog = load_catalogs (skylist, &Ncatalog, HOST_ID, HOSTDIR);
     40      if (!catalog) {
     41          fprintf (stderr, "ERROR loading catalogs from %s\n", CATDIR);
     42          exit (2);
     43      }
    3244      BrightCatalog *bcatalog = BrightCatalogMerge (catalog, Ncatalog);
    3345      if (!BrightCatalogSave (BCATALOG, bcatalog)) {
    34         abort();
     46          fprintf (stderr, "ERROR saving bright catalog from %s\n", CATDIR);
     47          exit (2);
    3548      }
    3649      break;
     
    4154      off_t Nimage;
    4255      ImageSubset *image = ImageSubsetLoad (IMAGES, &Nimage);
     56      if (!image) {
     57          fprintf (stderr, "ERROR loading image subset %s\n", CATDIR);
     58          exit (2);
     59      }
    4360     
    4461      // save the available image information in the static array in ImageOps.c
Note: See TracChangeset for help on using the changeset viewer.