forked from asreview/asreview
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add task manager for models and simulations (asreview#1861)
- Loading branch information
1 parent
19620cf
commit 7c7189b
Showing
10 changed files
with
531 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import argparse | ||
import textwrap | ||
import os | ||
|
||
from asreview.webapp.task_manager.task_manager import setup_logging | ||
from asreview.webapp.task_manager.task_manager import DEFAULT_TASK_MANAGER_HOST | ||
from asreview.webapp.task_manager.task_manager import DEFAULT_TASK_MANAGER_PORT | ||
from asreview.webapp.task_manager.task_manager import DEFAULT_TASK_MANAGER_WORKERS | ||
from asreview.webapp.task_manager.task_manager import TaskManager | ||
|
||
|
||
description = """\ | ||
This entry point launches an instance of ASReview's task manager. You can | ||
specify the host, port, and number of workers using environment variables | ||
(ASREVIEW_LAB_TASK_MANAGER_[WORKERS|HOST|PORT]) or CLI parameters, with | ||
environment variables taking precedence. | ||
""" | ||
|
||
|
||
def _arg_parser(argv): | ||
parser = argparse.ArgumentParser(description=textwrap.dedent(description).strip()) | ||
parser.add_argument( | ||
"--verbose", action="store_true", help="Enable verbose logging." | ||
) | ||
|
||
parser.add_argument( | ||
"--workers", | ||
default=DEFAULT_TASK_MANAGER_WORKERS, | ||
type=int, | ||
help=f"Specify the number of workers, defaults to {DEFAULT_TASK_MANAGER_WORKERS}.", | ||
) | ||
|
||
parser.add_argument( | ||
"--host", | ||
default=DEFAULT_TASK_MANAGER_HOST, | ||
type=str, | ||
help=f"Specify the task manager's host, defaults to {DEFAULT_TASK_MANAGER_HOST}.", | ||
) | ||
|
||
parser.add_argument( | ||
"--port", | ||
default=DEFAULT_TASK_MANAGER_PORT, | ||
type=int, | ||
help=f"Port of task manager, defaults to {DEFAULT_TASK_MANAGER_PORT}.", | ||
) | ||
|
||
return parser.parse_args(argv) | ||
|
||
|
||
def main(argv): | ||
args = _arg_parser(argv) | ||
|
||
verbose = os.getenv("ASREVIEW_LAB_TASK_MANAGER_VERBOSE", args.verbose) | ||
setup_logging(verbose=verbose) | ||
|
||
manager = TaskManager( | ||
max_workers=os.getenv("ASREVIEW_LAB_TASK_MANAGER_WORKERS", args.workers), | ||
host=os.getenv("ASREVIEW_LAB_TASK_MANAGER_HOST", args.host), | ||
port=os.getenv("ASREVIEW_LAB_TASK_MANAGER_PORT", args.port), | ||
) | ||
manager.start_manager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2019-2022 The ASReview Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from sqlalchemy import Boolean | ||
from sqlalchemy import Column | ||
from sqlalchemy import Integer | ||
from sqlalchemy import String | ||
from sqlalchemy.ext.declarative import declarative_base | ||
|
||
Base = declarative_base() | ||
|
||
|
||
class ProjectQueueModel(Base): | ||
"""Queue model""" | ||
|
||
__tablename__ = "queue" | ||
id = Column(Integer, primary_key=True) | ||
project_id = Column(String(250), nullable=False, unique=True) | ||
simulation = Column(Boolean, nullable=False, default=False) |
Oops, something went wrong.