def execute(self, heroku):
     base_url = get_base_url()
     self.out.log(
         "Server is running on {}. Press Ctrl+C to exit.".format(base_url))
     self.out.log("Launching the experiment...")
     try:
         result = _handle_launch_data("{}/launch".format(base_url),
                                      error=self.out.error,
                                      attempts=1)
     except Exception:
         # Show output from server
         self.dispatch[r"POST /launch"] = "launch_request_complete"
         heroku.monitor(listener=self.notify)
     else:
         if result["status"] == "success":
             self.out.log(result["recruitment_msg"])
             dashboard_url = "{}/dashboard/".format(get_base_url())
             self.display_dashboard_access_details(dashboard_url)
             if not self.no_browsers:
                 self.open_dashboard(dashboard_url)
             self.heroku = heroku
             self.out.log(
                 "Monitoring the Heroku Local server for recruitment or completion..."
             )
             heroku.monitor(listener=self.notify)
Exemple #2
0
 def execute(self, heroku):
     base_url = get_base_url()
     self.out.log(
         "Server is running on {}. Press Ctrl+C to exit.".format(base_url))
     self.out.log("Launching the experiment...")
     time.sleep(4)
     result = _handle_launch_data('{}/launch'.format(base_url),
                                  error=self.out.error)
     if result['status'] == 'success':
         self.out.log(result['recruitment_msg'])
         heroku.monitor(listener=self.notify)
Exemple #3
0
 def execute(self, heroku):
     base_url = get_base_url()
     self.out.log(
         "Server is running on {}. Press Ctrl+C to exit.".format(base_url))
     self.out.log("Launching the experiment...")
     try:
         result = _handle_launch_data('{}/launch'.format(base_url),
                                      error=self.out.error)
     except Exception:
         # Show output from server
         self.dispatch[r'POST /launch'] = 'launch_request_complete'
         heroku.monitor(listener=self.notify)
     else:
         if result['status'] == 'success':
             self.out.log(result['recruitment_msg'])
             self.heroku = heroku
             heroku.monitor(listener=self.notify)
Exemple #4
0
 def execute(self, heroku):
     base_url = get_base_url()
     self.out.log(
         "Server is running on {}. Press Ctrl+C to exit.".format(base_url))
     self.out.log("Launching the experiment...")
     time.sleep(4)
     try:
         result = _handle_launch_data("{}/launch".format(base_url),
                                      error=self.out.error)
     except Exception:
         # Show output from server
         self.dispatch[r"POST /launch"] = "launch_request_complete"
         heroku.monitor(listener=self.notify)
     else:
         if result["status"] == "success":
             self.out.log(result["recruitment_msg"])
             self.heroku = heroku
             heroku.monitor(listener=self.notify)
Exemple #5
0
    def execute(self, heroku):
        """Start the server, load the zip file into the database, then loop
        until terminated with <control>-c.
        """
        db.init_db(drop_all=True)
        self.out.log(
            "Ingesting dataset from {}...".format(os.path.basename(self.zip_path))
        )
        data.ingest_zip(self.zip_path)
        base_url = get_base_url()
        self.out.log("Server is running on {}. Press Ctrl+C to exit.".format(base_url))

        if self.exp_config.get("replay"):
            self.out.log("Launching the experiment...")
            time.sleep(4)
            _handle_launch_data("{}/launch".format(base_url), error=self.out.error)
            heroku.monitor(listener=self.notify)

        # Just run until interrupted:
        while self.keep_running():
            time.sleep(1)
Exemple #6
0
 def test_monitor_stops_iterating_when_told(self, heroku):
     heroku._stream = mock.Mock(return_value=["apple", "orange"])
     listener = mock.Mock()
     listener.return_value = heroku.MONITOR_STOP
     heroku.monitor(listener)
     listener.assert_has_calls([mock.call("apple")])
Exemple #7
0
 def test_monitor(self, heroku):
     heroku._stream = mock.Mock(return_value=["apple", "orange"])
     listener = mock.Mock()
     heroku.monitor(listener)
     listener.assert_has_calls([mock.call("apple"), mock.call("orange")])