evalquiz_proto.shared package
Subpackages
- evalquiz_proto.shared.generated package
- Module contents
Batch
BatchStatus
ByMetrics
Capability
Categorical
Complete
CourseSettings
EducationalObjective
Empty
Evaluation
EvaluationResult
EvaluationResultType
EvaluationSettings
GenerationEvaluationResult
GenerationResult
GenerationSettings
InternalConfig
LanguageModelEvaluation
LectureMaterial
ListOfStrings
MaterialServerBase
MaterialServerStub
MaterialUploadData
Metadata
Metric
Mode
ModuleStatus
MultipleChoice
MultipleResponse
Overwrite
PageFilter
PipelineModule
PipelineResult
PipelineServerBase
PipelineServerStub
PipelineStatus
Question
QuestionType
Relationship
String
ValueRange
- Module contents
Submodules
evalquiz_proto.shared.exceptions module
- exception evalquiz_proto.shared.exceptions.DataChunkNotBytesException[source]
Bases:
Exception
All chunks of a lecture material upload stream except the first one should be bytes.
- exception evalquiz_proto.shared.exceptions.EvaluationNotCompatibleWithInternalEvaluation[source]
Bases:
Exception
Evaluation is not compatible with InternalEvaluation. Please check the QuestionEvaluation.internal_evaluations mappings.
- exception evalquiz_proto.shared.exceptions.FileOverwriteNotPermittedException[source]
Bases:
Exception
A file is already present at the given location and is not permitted to be overwritten.
- exception evalquiz_proto.shared.exceptions.FirstDataChunkNotMetadataException[source]
Bases:
Exception
The first chunk of a lecture material upload stream should be of type Metadata.
- exception evalquiz_proto.shared.exceptions.LectureMaterialLocallyNotFoundException[source]
Bases:
Exception
The requested lecture material cannot be provided by the InternalMaterialController.
- exception evalquiz_proto.shared.exceptions.LectureMaterialNotFoundOnRemotesException[source]
Bases:
PipelineExecutionException
All remotes have been requested to provide the lecture material, but none of the remotes is able to.
- exception evalquiz_proto.shared.exceptions.MimetypeMismatchException[source]
Bases:
Exception
Expected mimetype does not match the given mimetype.
- exception evalquiz_proto.shared.exceptions.MimetypeNotDetectedException[source]
Bases:
Exception
Mimetype could not have been detected.
- exception evalquiz_proto.shared.exceptions.MissingDefaultInternalConfigAttributeException[source]
Bases:
Exception
A DefaultInternalConfig attribute was not be found.
- exception evalquiz_proto.shared.exceptions.NoMimetypeMappingException[source]
Bases:
Exception
The system could not map any file extension to the given mimetype, the mimetype could be invalid.
- exception evalquiz_proto.shared.exceptions.PipelineExecutionException[source]
Bases:
Exception
Unexpected behavior occurred in the execution of a PipelineModule
- exception evalquiz_proto.shared.exceptions.PipelineModuleCompositionNotValidException[source]
Bases:
Exception
Input and output datatypes at least one successive PipelineModule are not compatible.
- exception evalquiz_proto.shared.exceptions.PipelineModuleRuntimeInputException[source]
Bases:
Exception
The input given at runtime, does not match the defined input type of the InternalPipelineModule
- exception evalquiz_proto.shared.exceptions.ResultException[source]
Bases:
PipelineExecutionException
The generated result by the language model is not able to be further processed, due to incompatibilities.
- exception evalquiz_proto.shared.exceptions.ResultSectionNotFoundException[source]
Bases:
ResultException
The result section, marked with <result></result> tags was not found in the given text.
- exception evalquiz_proto.shared.exceptions.ResultSectionNotParsableException[source]
Bases:
ResultException
The structure of the result section, marked with <result></result> tags does not match the QuestionType.
evalquiz_proto.shared.internal_lecture_material module
- class evalquiz_proto.shared.internal_lecture_material.InternalLectureMaterial(local_path: Path, lecture_material: LectureMaterial)[source]
Bases:
LectureMaterial
A lecture material with an additional local path pointing to the file.
- cast_to_lecture_material() → LectureMaterial[source]
Casts self object to object of superclass: LectureMaterial. This method is required, as Python does not feature object type casting.
- Returns:
Self object casted into LectureMaterial.
- Return type:
- classmethod from_mongodb_document(document: dict[str, Any]) → InternalLectureMaterial[source]
Constructor of self from pymongo representation.
- Parameters:
document (dict[str, Any]) – Dictionary containing hash and serialized self.
- local_path: Path = PosixPath('.')
- to_mongodb_document() → dict[str, Any][source]
Encodes self to a representation that can be inserted by pymongo.
- Returns:
Dictionary containing hash and serialized self.
- Return type:
dict[str, Any]
- update_hash(rename_file: bool = False) → None[source]
Updates LectureMaterial hash with file contents.
- Parameters:
rename_file (bool, optional) – Filename of referenced file is changed to the updated hash, if set to True. Defaults to False.
- update_mimetype() → None[source]
Evaluates if given mimetype matches mimetype of file at local_path. Sets mimetype to new value, if mimetype does not match mimetype of file at local_path.
- Raises:
- verify_hash(other_hash: str | None = None) → bool[source]
Verifies that the file behind local_path is consistent with other_hash.
- Parameters:
other_hash – An optional hash parameter to test consistency against. If other_hash is None, self.hash is used as other_hash.
- Returns:
True, if other_hash matches calculated hash of file.
evalquiz_proto.shared.mimetype_resolver module
- class evalquiz_proto.shared.mimetype_resolver.MimetypeResolver[source]
Bases:
object
- static fixed_guess_extension(mimetype: str) → str | None[source]
Fixes the missing markdown type in Python’s mimetypes library.
- Parameters:
mimetype (str) – Mimetype to guess extension for.
- Returns:
Extension with leading dot.
- Return type:
Optional[str]
evalquiz_proto.shared.path_dictionary_controller module
- class evalquiz_proto.shared.path_dictionary_controller.PathDictionaryController(mongodb_client: MongoClient[dict[str, Any]], mongodb_database: str = 'local_path_db')[source]
Bases:
object
The PathDictionaryController manages str aliases to paths for local files. Multiple PathDictionaryController instances are able to share their state using MongoDB.
- async add_file_async(local_path: Path, hash: str, binary_iterator: AsyncIterator[bytes], overwrite: bool = True, name: str = '') → None[source]
A new file is created asynchronously at the specified location from a stream. System operations are carried out async to allow large file sizes and reduce the memory footprint.
- Parameters:
local_path – The system path to the location where the file is created.
hash – Hash to reference the file.
binary_iterator – Yields binary data of the file itself.
overwrite – Boolean to describe if an existing file can be overwritten.
name – Name or description of the file to add.
- Raises:
- copy_and_load_file(source_local_path: Path, destination_local_path: Path, hash: str, name: str = '') → None[source]
Copies file to destination and loads the destination file with self.load_file(…).
- Parameters:
source_local_path (Path) – Source file local path.
destination_local_path (Path) – Destination file local path.
hash (str) – Hash to reference the file.
- delete_file(hash: str) → None[source]
Deletes the reference to the file and the file itself from the filesystem.
- Parameters:
local_path – The system path to the file.
- async get_file_from_hash_async(hash: str, content_partition_size: int = 500000000) → tuple[str, AsyncIterator[bytes]][source]
Streams a local file using the given hash and returns its mimetype.
- Parameters:
hash (str) – Hash to reference the file.
content_partition_size (int, optional) – The maximum filesize in bytes that a packet can have. Defaults to 5*10**8.
- Raises:
KeyError – If file is not found under the given hash.
- Returns:
A tuple with the mimetype at the first index and the asynchronous iterator for streaming at the second index.
- Return type:
tuple[str, AsyncIterator[MaterialUploadData]]
- get_file_path_from_hash(hash: str) → Path[source]
Retrieves local path from hash.
- Parameters:
hash (str) – Hash to reference the file.
- Raises:
KeyError – If file is not found under the given hash.
- Returns:
The path to the local file.
- Return type:
Path
- get_material_hashes() → list[str][source]
Retrieves all hashes of the internally referenced files.
- Returns:
A set of strings
- get_material_name(hash: str) → str[source]
Returns material name from hash.
- Parameters:
hash (str) – Hash to reference the file.
- Raises:
KeyError – If file is not found under the given hash
- Returns:
Material name.
- Return type:
str