Store the notebook and stop run
338228
def on_train_end(self, **kwargs: Any) -> None:  
        ""
        self.client.log_artifact(run_id=self.run, local_path=self.nb_path)
        self.client.set_terminated(run_id=self.run)
590946
def save(self):
		
		with open(self.configuration_file, 'w') as file_h:
			file_h.write(self._serializer('dumps', self._storage))
213151
def run_stop_backup(cls):
        
        def handler(popen):
            assert popen.returncode != 0
            raise UserException('Could not stop hot backup')

        return cls._dict_transform(psql_csv_run(
                "SELECT file_name, "
                "  lpad(file_offset::text, 8, '0') AS file_offset "
                "FROM pg_{0}file_name_offset("
                "  pg_stop_backup())".format(cls._wal_name()),
                error_handler=handler))
952526
def stop(self):
        
        temp_archive = self.sdk.stop_archive(self.id)
        for k,v in iteritems(temp_archive.attrs()):
            setattr(self, k, v)
310756
def stop(self):
        '''
        
        '''
        # avoid getting called twice
        self.cleanup()
        if self.running:
            self.running = False
            self.timer_stop.set()
            self.timer.join()
1134104
def run_notebook(args, ssh_config_check):
    
    # Check that ssh is setup.  Currently notebooks require ssh for tunelling.
    ssh_config_check()
    if args.only_check_config:
        return

    # If the user requested a specific version of the notebook server,
    # get the executable id.
    if args.version is not None:
        executable = get_app_from_path('app-{0}/{1}'.format(NOTEBOOK_APP, args.version))
        if executable is not None and 'id' in executable:
            executable = executable['id']
        else:
            msg = RED('Warning:') + ' Invalid notebook version: {0}\nValid versions are: '.format(args.version)
            msg += BOLD('{0}'.format(str(get_notebook_app_versions())))
            err_exit(msg)
    else:
        executable = 'app-{0}'.format(NOTEBOOK_APP)

    # Compose the command to launch the notebook
    cmd = ['dx', 'run', executable, '-inotebook_type={0}'.format(args.notebook_type)]
    cmd += ['-iinput_files={0}'.format(f) for f in args.notebook_files]
    cmd += ['-itimeout={0}'.format(args.timeout), '-y', '--brief', '--allow-ssh', '--instance-type', args.instance_type]
    if args.spark:
        cmd += ['-iinstall_spark=true']
    if args.snapshot:
        cmd += ['-isnapshot={0}'.format(args.snapshot)]
    job_id = subprocess.check_output(cmd).strip()

    poll_for_server_running(job_id)

    if args.notebook_type in {'jupyter', 'jupyter_lab', 'jupyter_notebook'}:
        remote_port = 8888

    setup_ssh_tunnel(job_id, args.port, remote_port)

    if args.open_server:
        multi_platform_open('http://localhost:{0}'.format(args.port))
        print('A web browser should have opened to connect you to your notebook.')
    print('If no browser appears, or if you need to reopen a browser at any point, you should be able to point your browser to http://localhost:{0}'.format(args.port))
197138
def halt_running():
    ''''''
    vultr = Vultr(API_KEY)

    try:
            serverList = vultr.server.list()
            #logging.info('Listing servers:\n%s', dumps(
            #serverList, indent=2
        #))
    except VultrError as ex:
        logging.error('VultrError: %s', ex)

    for serverID in serverList:
        if serverList[serverID]['power_status'] == 'running':
            logging.info(serverList[serverID]['label'] + " will be gracefully shutdown.")
            vultr.server.halt(serverID)
513038
def save(self):
        """"""
        if self._sheet.readonly:
            raise ReadOnlyException
        if not self._changed:
            # nothing to save
            return
        gd_client = self._sheet.client
        assert gd_client is not None
        try:
            entry = gd_client.UpdateRow(self._entry, self._data)
        except RequestError as e:
            error_data = e.args[0]
            if error_data.status == 403:
                #  Forbidden
                raise
            if error_data.status == 409:
                # conflict
                raise
            else:
                raise
        self._entry = entry
        # reset `_changed` flag
        self._changed = False
        return entry
498307
def _save_nb(nb_name):
    
    display(Javascript('IPython.notebook.save_checkpoint();'))
    display(Javascript('IPython.notebook.save_notebook();'))
    print('Saving notebook...', end=' ')

    if _wait_for_save(nb_name):
        print("Saved '{}'.".format(nb_name))
    else:
        logging.warning(
            "Could not save your notebook (timed out waiting for "
            "IPython save). Make sure your notebook is saved "
            "and export again."
        )
606943
def _stop(self):
        
        engine = self.current_engine()
        if "vm" in self._controller.computes:
            yield from self._controller.delete_compute("vm")
        if engine.running:
            log.info("")
            yield from engine.stop()
943032
def launch_notebook(request, username, notebook_context):
    
    # The notebook manage now tries too hard to get the port allocated for the notebook user, making it slow
    # TODO: Manage a proper state e.g. using Redis
    notebook_info = launch_on_demand(request, username, notebook_context)

    # Jump to the detault notebook
    proxy_route = request.route_url("notebook_proxy", remainder="notebooks/{}".format(notebook_info["notebook_name"]))
    proxy_route = route_to_alt_domain(request, proxy_route)

    return HTTPFound(proxy_route)
1014753
def run(self):
        
        try:
            Control().cursor_hide().write(file=self.file)
            super().run()
        except KeyboardInterrupt:
            self.stop()
        finally:
            Control().cursor_show().write(file=self.file)
696657
def save(self):
        

        data = {
            'waitForSync': self.waitForSync,
            'journalSize': self.journalSize,
        }

        self.resource(self.name).properties.put(data)
834654
def run_notebook(self, nb, f):
        """"""

        if PYTHON_MAJOR_VERSION == 3:
            kernel_name = 'python3'
        elif PYTHON_MAJOR_VERSION == 2:
            kernel_name = 'python2'
        else:
            raise Exception('Only Python 2 and 3 are supported')
        ep = ExecutePreprocessor(timeout=600, kernel_name=kernel_name)
        try:
            ep.preprocess(nb, {'metadata': {'path': '.'}})
        except CellExecutionError:
            msg = 'Error executing the notebook "%s".\n\n' % f.name
            msg += 'See notebook "%s" for the traceback.' % f.name
            print(msg)
            raise
        finally:
            nbformat.write(nb, f)
1153595
def store_session():
    
    from rafcon.gui.singleton import state_machine_manager_model, global_runtime_config
    from rafcon.gui.models.auto_backup import AutoBackupModel
    from rafcon.gui.models import AbstractStateModel
    from rafcon.gui.singleton import main_window_controller
    # check if there are dirty state machines -> use backup file structure maybe it is already stored
    for sm_m in state_machine_manager_model.state_machines.values():
        if sm_m.auto_backup:
            if sm_m.state_machine.marked_dirty:
                sm_m.auto_backup.perform_temp_storage()
        else:
            # generate a backup
            sm_m.auto_backup = AutoBackupModel(sm_m)

    # collect order of tab state machine ids from state machines editor and find selected state machine page number
    state_machines_editor_ctrl = main_window_controller.get_controller('state_machines_editor_ctrl')
    number_of_pages = state_machines_editor_ctrl.view['notebook'].get_n_pages()
    selected_page_number = None
    list_of_tab_meta = []
    for page_number in range(number_of_pages):
        page = state_machines_editor_ctrl.view['notebook'].get_nth_page(page_number)
        sm_id = state_machines_editor_ctrl.get_state_machine_id_for_page(page)
        if sm_id == state_machine_manager_model.selected_state_machine_id:
            selected_page_number = page_number

        # backup state machine selection
        selection_of_sm = []
        for model in state_machine_manager_model.state_machines[sm_id].selection.get_all():
            if isinstance(model, AbstractStateModel):
                # TODO extend to full range of selection -> see core_identifier action-module
                selection_of_sm.append(model.state.get_path())

        list_of_tab_meta.append({'backup_meta': state_machine_manager_model.state_machines[sm_id].auto_backup.meta,
                                 'selection': selection_of_sm})

    # store final state machine backup meta data to backup session tabs and selection for the next run
    global_runtime_config.set_config_value('open_tabs', list_of_tab_meta)
    global_runtime_config.set_config_value('selected_state_machine_page_number', selected_page_number)
906166
def _save_notebook(self, os_path, nb):
        """"""
        with self.atomic_writing(os_path, encoding='utf-8') as f:
            if ftdetect(os_path) == 'notebook':
                nbformat.write(nb, f, version=nbformat.NO_CONVERT)
            elif ftdetect(os_path) == 'markdown':
                nbjson = nbformat.writes(nb, version=nbformat.NO_CONVERT)
                markdown = convert(nbjson,
                                   informat='notebook',
                                   outformat='markdown',
                                   strip_outputs=self.strip_outputs)
                f.write(markdown)
1357793
function execute(req, res) {
  this.log.notice('background saving started by pid %s', process.pid);
  function onSave(err) {
    /* istanbul ignore next: not prepared to mock this right now */
    if(err) return this.log.warning('background save failed: %s', err.message);
    this.log.notice('background saving terminated with success')
  }
  Persistence.save(this.state.store, this.state.conf, onSave.bind(this));
  res.send(null, Constants.BGSAVE);
}