Skip to content

Commit

Permalink
Merge pull request #160 from ufal/webui-minor-bugfixes
Browse files Browse the repository at this point in the history
Minor bugfixes related to the web interface
  • Loading branch information
kasnerz authored Dec 2, 2024
2 parents 2315e97 + 60c7080 commit dcbf53d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
8 changes: 6 additions & 2 deletions factgenie/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions factgenie/datasets/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion factgenie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion factgenie/static/js/browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $('<div>', { class: "p-2 extra-fields" });

Expand Down
3 changes: 0 additions & 3 deletions factgenie/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
CROWDSOURCING_CONFIG_DIR,
)

file_handler = logging.FileHandler("error.log")
file_handler.setLevel(logging.ERROR)

logger = logging.getLogger(__name__)


Expand Down

0 comments on commit dcbf53d

Please sign in to comment.