DataArchive

class emmet.core.testing_utils.DataArchive(**data)

Bases: BaseModel

Tool to compress test data into a lower disk / innode use file.

Parameters:

files (dict[str, bytes])

classmethod from_directory(path)

Find all files in . and parse them.

Parameters:

path (Annotated[str | Path | DirEntry[str] | PathLike[str], PlainSerializer(func=~emmet.core.types.typing.<lambda>, return_type=str, when_used=always)])

to_json(file_name)

Write all contents to JSON.

Return type:

None

Parameters:

file_name (Annotated[str | Path | DirEntry[str] | PathLike[str], PlainSerializer(func=~emmet.core.types.typing.<lambda>, return_type=str, when_used=always)])

classmethod extract(cls, archive_path)

Extract all bytes data from a JSON archive.

Return type:

Generator[Path]

Parameters:

archive_path (Annotated[str | Path | DirEntry[str] | PathLike[str], PlainSerializer(func=~emmet.core.types.typing.<lambda>, return_type=str, when_used=always)])

Parameters

archive_pathFSPathType

The name of the JSON file

Returns

pandas DataFrame representing the parsed data.

static extract_obj(archive_path, file_name, func, *args, **kwargs)

Extract a single file and apply a mapping to it.

Return type:

Any

Parameters:
  • archive_path (Annotated[str | Path | DirEntry[str] | PathLike[str], PlainSerializer(func=~emmet.core.types.typing.<lambda>, return_type=str, when_used=always)])

  • file_name (str)

  • func (Callable)

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].