Changeset ff60cfa for src


Ignore:
Timestamp:
Jun 27, 2012, 4:07:20 PM (13 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
545446
Parents:
306f60
git-author:
Frederik Heber <heber@…> (02/15/12 14:14:19)
git-committer:
Frederik Heber <heber@…> (06/27/12 16:07:20)
Message:

Controller has new function addjobs.

  • addjobs parses mpqc input file and creates MPQCCommandJob which is sent to send jobs
  • old sendjobs is now createjobs which creates empty SystemCommandJob.
  • added new class GlobalJobId which holds a global JobId such that FragmentJobs created by Controller each have a unique id. NOTE: This should probably be replaced by IdPool implementation when Fragmentation/Automation is integrated into rest of molecuilder.
  • dummyInit() to have MPQCCommandJob instances known to FragmentScheduler.
  • TESTFIX: Adapted regression tests Fragmentation/Automation adding-jobs, server-worker, and completerun due to command token change.
Location:
src/Fragmentation/Automation
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Automation/FragmentScheduler.cpp

    r306f60 rff60cfa  
    3434#include "CodePatterns/Info.hpp"
    3535#include "CodePatterns/Log.hpp"
     36#include "Jobs/MPQCCommandJob.hpp"
    3637#include "Jobs/SystemCommandJob.hpp"
    3738#include "JobId.hpp"
     
    3940#include "FragmentScheduler.hpp"
    4041
    41 FragmentJob::ptr FragmentScheduler::NoJob(new SystemCommandJob(std::string("/bin/false"), std::string("NoJob"), JobId::NoJob));
     42FragmentJob::ptr FragmentScheduler::NoJob(new SystemCommandJob(std::string("/bin/true"), std::string("dosomething"), JobId::NoJob));
     43
     44/** Helper function to enforce binding of FragmentWorker to possible derived
     45 * FragmentJob classes.
     46 */
     47void dummyInit() {
     48  SystemCommandJob("/bin/false", "something", JobId::IllegalJob);
     49  MPQCCommandJob("nofile", JobId::IllegalJob);
     50}
    4251
    4352/** Constructor of class FragmentScheduler.
  • src/Fragmentation/Automation/Makefile.am

    r306f60 rff60cfa  
    5050  Controller/Commands/ReceiveJobsOperation.cpp \
    5151  Controller/Commands/SendResultsOperation.cpp \
    52   Controller/Commands/ShutdownOperation.cpp
     52  Controller/Commands/ShutdownOperation.cpp \
     53  GlobalJobId.cpp
    5354
    5455FRAGMENTATIONAUTOMATIONHEADER = \
     
    6263  Controller/Commands/ReceiveJobsOperation.hpp \
    6364  Controller/Commands/SendResultsOperation.hpp \
    64   Controller/Commands/ShutdownOperation.hpp
     65  Controller/Commands/ShutdownOperation.hpp \
     66  GlobalJobId.hpp
    6567
    6668noinst_LTLIBRARIES += libMolecuilderFragmentationAutomation.la
  • src/Fragmentation/Automation/controller.cpp

    r306f60 rff60cfa  
    2727#include "CodePatterns/MemDebug.hpp"
    2828
     29#include <fstream>
    2930#include <iostream>
     31#include <map>
     32#include <sstream>
     33#include <streambuf>
    3034#include <vector>
    31 #include <map>
    3235
    3336#include "atexit.hpp"
     
    3942#include "Controller/Commands/SendResultsOperation.hpp"
    4043#include "Controller/Commands/ShutdownOperation.hpp"
     44#include "GlobalJobId.hpp"
     45#include "Jobs/MPQCCommandJob.hpp"
    4146#include "Jobs/SystemCommandJob.hpp"
    4247#include "Results/FragmentResult.hpp"
     
    4449enum CommandIndices {
    4550  UnknownCommandIndex = 0,
    46   SendJobsIndex = 1,
    47   CheckResultsIndex = 2,
    48   ReceiveResultsIndex = 3,
    49   ShutdownIndex = 4
     51  AddJobsIndex = 1,
     52  CreateJobsIndex = 2,
     53  CheckResultsIndex = 3,
     54  ReceiveResultsIndex = 4,
     55  ShutdownIndex = 5
    5056};
    5157
     58// TODO: replace this instance by a IdPool owned by controller.
     59GlobalJobId globalId;
     60
    5261void createjobs(std::vector<FragmentJob::ptr> &jobs)
    5362{
    54   FragmentJob::ptr testJob( new SystemCommandJob( std::string("cat"), std::string("Nothing"), 1) );
    55   FragmentJob::ptr othertestJob( new SystemCommandJob( std::string("cat"), std::string("Nothing"), 2) );
     63  FragmentJob::ptr testJob( new SystemCommandJob( std::string("cat"), std::string("Nothing"), globalId.getNextId()) );
     64  FragmentJob::ptr othertestJob( new SystemCommandJob( std::string("cat"), std::string("Nothing"), globalId.getNextId()) );
    5665  jobs.push_back(testJob);
    5766  jobs.push_back(othertestJob);
     67}
     68
     69void parsejob(std::vector<FragmentJob::ptr> &jobs, const std::string &filename)
     70{
     71  std::ifstream file;
     72  file.open(filename.c_str());
     73  ASSERT( file.good(), "parsejob() - file "+filename+" does not exist.");
     74  std::string output((std::istreambuf_iterator<char>(file)),
     75      std::istreambuf_iterator<char>());
     76  FragmentJob::ptr testJob( new MPQCCommandJob(output, globalId.getNextId()) );
     77  jobs.push_back(testJob);
     78  file.close();
     79  LOG(1, "INFO: Added MPQCCommandJob from file "+filename+".");
    5880}
    5981
     
    136158
    137159  size_t Exitflag = 0;
    138   std::map<std::string, CommandIndices> CommandsMap;
    139   CommandsMap.insert( std::make_pair("sendjobs", SendJobsIndex) );
     160  typedef std::map<std::string, CommandIndices> CommandsMap_t;
     161  CommandsMap_t CommandsMap;
     162  CommandsMap.insert( std::make_pair("addjobs", AddJobsIndex) );
     163  CommandsMap.insert( std::make_pair("createjobs", CreateJobsIndex) );
    140164  CommandsMap.insert( std::make_pair("checkresults", CheckResultsIndex) );
    141165  CommandsMap.insert( std::make_pair("receiveresults", ReceiveResultsIndex) );
     
    144168  {
    145169    // Check command line arguments.
    146     if (argc != 4)
     170    if (argc < 4)
    147171    {
    148       std::cerr << "Usage: " << argv[0] << " <host> <port> <command>" << std::endl;
     172      std::cerr << "Usage: " << argv[0] << " <host> <port> <command> [options to command]" << std::endl;
     173      std::cerr << "List of available commands:" << std::endl;
     174      for(CommandsMap_t::const_iterator iter = CommandsMap.begin();
     175          iter != CommandsMap.end(); ++iter) {
     176        std::cerr << "\t" << iter->first << std::endl;
     177      }
    149178      return 1;
    150179    }
     
    154183
    155184    switch(getCommandIndex(CommandsMap, argv[3])) {
    156       case SendJobsIndex:
     185      case AddJobsIndex:
     186      {
     187        std::vector<FragmentJob::ptr> jobs;
     188        if (argc == 4) {
     189          ELOG(1, "Please add a filename for the MPQCCommandJob.");
     190        } else {
     191          for (int argcount = 4; argcount < argc; ++argcount) {
     192            LOG(1, "INFO: Parsing job for file " << argv[argcount] << ".");
     193            parsejob(jobs, argv[argcount]);
     194          }
     195          addjobs(controller, jobs);
     196          sendjobs(controller, argv[1], argv[2]);
     197        }
     198        break;
     199      }
     200      case CreateJobsIndex:
    157201      {
    158202        std::vector<FragmentJob::ptr> jobs;
     
    189233
    190234    switch(getCommandIndex(CommandsMap, argv[3])) {
    191       case SendJobsIndex:
     235      case AddJobsIndex:
     236      case CreateJobsIndex:
    192237        break;
    193238      case CheckResultsIndex:
Note: See TracChangeset for help on using the changeset viewer.