Skip to content

Commit

Permalink
Isolate read_data function from webapp to prevent circular imports (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
J535D165 authored May 8, 2023
1 parent 8ea01ec commit 407adaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions asreview/entry_points/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from asreview.config import DEFAULT_QUERY_STRATEGY
from asreview.config import EMAIL_ADDRESS
from asreview.config import GITHUB_PAGE
from asreview.data import ASReviewData
from asreview.data import load_data
from asreview.entry_points.base import BaseEntryPoint
from asreview.entry_points.base import _base_parser
Expand All @@ -42,7 +43,6 @@
from asreview.settings import ASReviewSettings
from asreview.types import type_n_queries
from asreview.utils import get_random_state
from asreview.webapp.io import read_data

ASCII_MSG_SIMULATE = """
---------------------------------------------------------------------------------
Expand Down Expand Up @@ -120,7 +120,10 @@ def execute(self, argv): # noqa

# collect command line arguments and pass them to the reviewer
if exist_new_labeled_records:
as_data = read_data(project)
fp_data = Path(
project.project_path, "data", project.config["dataset_path"]
)
as_data = ASReviewData.from_file(fp_data)
prior_idx = args.prior_idx

classifier_model = get_classifier(settings.model)
Expand Down
5 changes: 3 additions & 2 deletions asreview/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
from asreview.config import PROJECT_MODE_SIMULATE
from asreview.config import PROJECT_MODES
from asreview.config import SCHEMA
from asreview.data import ASReviewData
from asreview.state.errors import StateNotFoundError
from asreview.state.sqlstate import SQLiteState
from asreview.utils import asreview_path
from asreview.webapp.io import read_data

PATH_PROJECT_CONFIG = "project.json"
PATH_PROJECT_CONFIG_LOCK = "project.json.lock"
Expand Down Expand Up @@ -385,7 +385,8 @@ def add_dataset(self, file_name):
self.update_config(dataset_path=file_name)

# fill the pool of the first iteration
as_data = read_data(self)
fp_data = Path(self.project_path, "data", self.config["dataset_path"])
as_data = ASReviewData.from_file(fp_data)

with open_state(self.project_path, read_only=False) as state:
# save the record ids in the state file
Expand Down

0 comments on commit 407adaa

Please sign in to comment.