diff --git a/factgenie/campaign.py b/factgenie/campaign.py index 1e6fdd80..17a0c831 100644 --- a/factgenie/campaign.py +++ b/factgenie/campaign.py @@ -43,8 +43,8 @@ def __init__(self, campaign_id): self.db_path = os.path.join(self.dir, "db.csv") self.metadata_path = os.path.join(self.dir, "metadata.json") - self.load_db() self.load_metadata() + self.load_db() def get_finished_examples(self): # load all the JSONL files in the "files" subdirectory @@ -63,8 +63,12 @@ def update_db(self, db): db.to_csv(self.db_path, index=False) def load_db(self): - dtype_dict = {"annotator_id": str, "start": float, "end": float} + # no db for external campaigns + if self.metadata.get("mode") == CampaignMode.EXTERNAL: + self.db = pd.DataFrame() + return + dtype_dict = {"annotator_id": str, "start": float, "end": float} with open(self.db_path) as f: self.db = pd.read_csv(f, dtype=dtype_dict) diff --git a/factgenie/datasets/basic.py b/factgenie/datasets/basic.py index f9c053e3..5634a009 100644 --- a/factgenie/datasets/basic.py +++ b/factgenie/datasets/basic.py @@ -98,7 +98,9 @@ def render(self, example): class JSONDataset(BasicDataset): def load_examples(self, split, data_path): examples_path = data_path / f"{split}.json" + if not examples_path.exists(): + logger.warning("No examples found for the dataset.") examples = [] else: with open(examples_path) as f: diff --git a/factgenie/models.py b/factgenie/models.py index 255d3582..f0d026d6 100644 --- a/factgenie/models.py +++ b/factgenie/models.py @@ -216,7 +216,7 @@ def __init__(self, config, **kwargs): # Required for OpenAI API but make sense in general too # TODO make it more pydantic / Python friendly self._schema["additionalProperties"] = False - self._schema["$defs"]["Annotation"]["additionalProperties"] = False + self._schema["$defs"]["SpanAnnotation"]["additionalProperties"] = False logger.warning(f"The schema is set to\n{self._schema}.\n\tCheck that your prompt is compatible!!! ") # access the later used config keys early to log them once and test if they are present diff --git a/factgenie/static/js/browse.js b/factgenie/static/js/browse.js index a676c560..45050a4f 100644 --- a/factgenie/static/js/browse.js +++ b/factgenie/static/js/browse.js @@ -211,7 +211,7 @@ function getExampleLevelFields(annotations) { // show `outputs.flags`, `outputs.options`, and `outputs.textFields` var flags = annotations.flags; var options = annotations.options; - var textFields = annotations.textFields; + var textFields = annotations.text_fields; var html = $('
', { class: "p-2 extra-fields" }); diff --git a/factgenie/workflows.py b/factgenie/workflows.py index ae065e86..4a91bc51 100644 --- a/factgenie/workflows.py +++ b/factgenie/workflows.py @@ -39,9 +39,6 @@ CROWDSOURCING_CONFIG_DIR, ) -file_handler = logging.FileHandler("error.log") -file_handler.setLevel(logging.ERROR) - logger = logging.getLogger(__name__)