Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to restore Python 3.8 compatibility #1

Merged
merged 5 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.9', '3.10' ]
python-version: [ '3.8', '3.9', '3.10' ]
max-parallel: 2

steps:
Expand Down
2 changes: 1 addition & 1 deletion app/data/anno_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _generate_examples(self, filepaths: List[Path]) -> Iterable[Tuple[str, Dict]
def generate_examples(filepaths: List[Path]) -> Iterable[Tuple[str, Dict]]:
id_ = 1
for filepath in filepaths:
with (open(str(filepath), "r") as f):
with open(str(filepath), "r") as f:
annotations = json.load(f)
filtered = filter_by_concept_ids(annotations)
for project in filtered["projects"]:
Expand Down
4 changes: 2 additions & 2 deletions app/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class Annotation(BaseModel):
categories: Optional[List[str]] = Field(default=None, description="The categories to which the annotation concept belongs")
accuracy: Optional[float] = Field(default=None, description="The confidence score of the annotation")
text: Optional[str] = Field(default=None, description="The string literal of the annotation span")
meta_anns: Optional[dict] = Field(default=None, description="The meta annotations")
athena_ids: Optional[list[dict]] = Field(default=None, description="The OHDSI Athena concept IDs")
meta_anns: Optional[Dict] = Field(default=None, description="The meta annotations")
athena_ids: Optional[List[Dict]] = Field(default=None, description="The OHDSI Athena concept IDs")

@root_validator()
def _validate(cls, values: Dict[str, Any]) -> Dict[str, Any]:
Expand Down
8 changes: 4 additions & 4 deletions app/processors/metrics_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

ANCHOR_DELIMITER = ";"
DOC_SPAN_DELIMITER = "_"
STATE_MISSING = hashlib.sha1("MISSING".encode("utf-8"), usedforsecurity=False).hexdigest()
META_STATE_MISSING = hashlib.sha1("{}".encode("utf-8"), usedforsecurity=False).hexdigest()
STATE_MISSING = hashlib.sha1("MISSING".encode("utf-8")).hexdigest()
META_STATE_MISSING = hashlib.sha1("{}".encode("utf-8")).hexdigest()


def sanity_check_model_with_trainer_export(trainer_export: Union[str, TextIO, Dict],
Expand Down Expand Up @@ -425,12 +425,12 @@ def _filter_docspan_by_value(docspan2value: Dict, value: str) -> Dict:


def _get_hashed_annotation_state(annotation: Dict, state_keys: Set[str]) -> str:
return hashlib.sha1("_".join([str(annotation.get(key)) for key in state_keys]).encode("utf-8"), usedforsecurity=False).hexdigest()
return hashlib.sha1("_".join([str(annotation.get(key)) for key in state_keys]).encode("utf-8")).hexdigest()


def _get_hashed_meta_annotation_state(meta_anno: Dict) -> str:
meta_anno = {key: val for key, val in sorted(meta_anno.items(), key=lambda item: item[0])} # may not be necessary
return hashlib.sha1(str(meta_anno).encode("utf=8"), usedforsecurity=False).hexdigest()
return hashlib.sha1(str(meta_anno).encode("utf=8")).hexdigest()


def _get_cohens_kappa_coefficient(y1_labels: List, y2_labels: List) -> float:
Expand Down
Loading