Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
major webapi service refactorings / added progress monitor for websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
forman committed Dec 9, 2016
1 parent 205ef89 commit 5e3e6ea
Show file tree
Hide file tree
Showing 12 changed files with 481 additions and 339 deletions.
3 changes: 2 additions & 1 deletion cate/core/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

import os.path

DEFAULT_DATA_PATH = os.path.expanduser(os.path.join('~', '.cate'))
DEFAULT_DATA_DIR_NAME = '.cate'
DEFAULT_DATA_PATH = os.path.join(os.path.expanduser('~'), DEFAULT_DATA_DIR_NAME)
DEFAULT_CONF_FILE = os.path.join(DEFAULT_DATA_PATH, 'conf.py')

_LOCAL_CONF_FILE = 'cate-conf.py'
Expand Down
2 changes: 1 addition & 1 deletion cate/ds/esa_cci_odp.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def query(self, name: str = None, monitor: Monitor = Monitor.NONE) -> Sequence['
result = [data_source for data_source in self._data_sources if data_source.matches_filter(name)]
else:
result = self._data_sources
return sorted(result, key=lambda data_source: data_source.name)
return result

def _repr_html_(self) -> str:
self._init_data_sources()
Expand Down
16 changes: 8 additions & 8 deletions cate/ui/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
"""

import argparse
import importlib
import os
import os.path
import pprint
Expand All @@ -115,6 +114,7 @@
from cate.ui.webapi import start_service_subprocess, stop_service_subprocess, read_service_info, is_service_running
from cate.ui.workspace import WorkspaceError
from cate.ui.wsmanag import WorkspaceManager, WebAPIWorkspaceManager
from cate.ui.conf import DEFAULT_DATA_PATH
from cate.version import __version__

# Explicitly load Cate-internal plugins.
Expand Down Expand Up @@ -152,7 +152,7 @@
WRITE_FORMAT_NAMES = OBJECT_IO_REGISTRY.get_format_names('w')
READ_FORMAT_NAMES = OBJECT_IO_REGISTRY.get_format_names('r')

WEBAPI_INFO_FILE = os.path.join(os.path.expanduser('~'), '.cate', 'webapi.json')
WEBAPI_INFO_FILE = os.path.join(DEFAULT_DATA_PATH, 'webapi.json')


def _default_workspace_manager_factory() -> WorkspaceManager:
Expand Down Expand Up @@ -670,14 +670,14 @@ def configure_parser_and_subparsers(cls, parser, subparsers):
def _execute_init(cls, command_args):
workspace_manager = _new_workspace_manager()
workspace_manager.new_workspace(_base_dir(command_args.base_dir),
save=True, description=command_args.description)
do_save=True, description=command_args.description)
print('Workspace initialized.')

@classmethod
def _execute_new(cls, command_args):
workspace_manager = _new_workspace_manager()
workspace_manager.new_workspace(_base_dir(command_args.base_dir),
save=False, description=command_args.description)
do_save=False, description=command_args.description)
print('Workspace created.')

@classmethod
Expand All @@ -690,10 +690,10 @@ def _execute_open(cls, command_args):
def _execute_close(cls, command_args):
workspace_manager = _new_workspace_manager()
if command_args.close_all:
workspace_manager.close_all_workspaces(save=command_args.save)
workspace_manager.close_all_workspaces(do_save=command_args.save)
print('All workspaces closed.')
else:
workspace_manager.close_workspace(_base_dir(command_args.base_dir), save=command_args.save)
workspace_manager.close_workspace(_base_dir(command_args.base_dir), do_save=command_args.save)
print('Workspace closed.')

@classmethod
Expand Down Expand Up @@ -742,7 +742,7 @@ def _execute_run(cls, command_args):
@classmethod
def _execute_status(cls, command_args):
workspace_manager = _new_workspace_manager()
workspace = workspace_manager.get_workspace(_base_dir(command_args.base_dir), open=False)
workspace = workspace_manager.get_workspace(_base_dir(command_args.base_dir), do_open=False)
cls._print_workspace(workspace)

# noinspection PyUnusedLocal
Expand Down Expand Up @@ -770,7 +770,7 @@ def _execute_exit(cls, command_args):
answer = input('Do you really want to exit interactive mode ([y]/n)? ')
if not answer or answer.lower() == 'y':
workspace_manager = _new_workspace_manager()
workspace_manager.close_all_workspaces(save=command_args.save_all)
workspace_manager.close_all_workspaces(do_save=command_args.save_all)
stop_service_subprocess(caller=CLI_NAME, service_info_file=WEBAPI_INFO_FILE)

@classmethod
Expand Down
36 changes: 36 additions & 0 deletions cate/ui/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os.path

from cate.core.conf import DEFAULT_DATA_PATH

SCRATCH_WORKSPACES_DIR_NAME = 'scratch-workspaces'
SCRATCH_WORKSPACES_PATH = os.path.join(DEFAULT_DATA_PATH, SCRATCH_WORKSPACES_DIR_NAME)

WORKSPACE_DATA_DIR_NAME = '.cate-workspace'
WORKSPACE_WORKFLOW_FILE_NAME = 'workflow.json'

# {{cate-config}}
# allow a 100 ms period between two progress messages sent to the client
WEBAPI_PROGRESS_DEFER_PERIOD = 0.1

# {{cate-config}}
# allow two minutes timeout for any synchronous workspace I/O
WEBAPI_WORKSPACE_TIMEOUT = 2 * 60.0

# {{cate-config}}
# allow one hour timeout for any synchronous workflow resource processing
WEBAPI_RESOURCE_TIMEOUT = 60 * 60.0

# {{cate-config}}
# allow one hour extra timeout for matplotlib to block the WebAPI service's main thread by showing a Qt window
WEBAPI_PLOT_TIMEOUT = 60 * 60.0

# {{cate-config}}
# By default, WebAPI service will auto-exit after 2 hours of inactivity (if caller='cate', the CLI)
WEBAPI_ON_INACTIVITY_AUTO_EXIT_AFTER = 120 * 60.0

# {{cate-config}}
# By default, WebAPI service will auto-exit after 5 seconds if all workspaces are closed (if caller='cate', the CLI)
WEBAPI_ON_ALL_CLOSED_AUTO_EXIT_AFTER = 5.0

# {{cate-config}}
WEBAPI_LOG_FILE = os.path.join(DEFAULT_DATA_PATH, 'webapi.log')
61 changes: 0 additions & 61 deletions cate/ui/service.py

This file was deleted.

Loading

0 comments on commit 5e3e6ea

Please sign in to comment.