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

feat: Initial implementation of dataset versioning #370

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/sec_certs/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing import Any, Generic, Iterator, TypeVar, cast

import pandas as pd
from setuptools_scm import get_version

from sec_certs import constants
from sec_certs.configuration import config
Expand Down Expand Up @@ -50,6 +51,7 @@ class Dataset(Generic[CertSubType, AuxiliaryDatasetsSubType], ComplexSerializabl

@dataclass
class DatasetInternalState(ComplexSerializableType):
sec_certs_version: str = get_version(root="..", local_scheme="no-local-version")
meta_sources_parsed: bool = False
artifacts_downloaded: bool = False
pdfs_converted: bool = False
Expand Down Expand Up @@ -204,6 +206,12 @@ def from_dict(cls: type[DatasetSubType], dct: dict) -> DatasetSubType:
@classmethod
def from_json(cls: type[DatasetSubType], input_path: str | Path, is_compressed: bool = False) -> DatasetSubType:
dset = cast("DatasetSubType", ComplexSerializableType.from_json(input_path, is_compressed))
dset_version = dset.state.sec_certs_version
tool_version = get_version(root="..", local_scheme="no-local-version")

if dset_version != tool_version:
logger.warning(f"Dataset version: {dset_version} does not match current version of tool: {tool_version}!")

dset._root_dir = Path(input_path).parent.absolute()
dset._set_local_paths()
return dset
Expand Down