altimeter.core.artifact_io package¶
Submodules¶
altimeter.core.artifact_io.exceptions module¶
Exceptions for artifact I/O
-
exception
InvalidS3URIException¶ Bases:
altimeter.core.exceptions.AltimeterExceptionAn S3 uri could not be parsed.
altimeter.core.artifact_io.reader module¶
Classes for ArtifactReaders. An ArtifactReader reads a scan artifact dict from something - e.g. a file, s3 key, etc.
-
class
ArtifactReader¶ Bases:
abc.ABCArtifactReaders read JSON artifacts from locations - e.g. s3, filesystem, etc.
-
classmethod
from_artifact_path(artifact_path)¶ Create an ArtifactReader based on an artifact path. This either returns a FileArtifactReader or an S3ArtifactReader depending on the value of artifact_path
- Return type
-
read_json(path)¶ Read a json artifact
- Parameters
path (
str) – path to artifact to read- Return type
Dict[str,Any]- Returns
artifact content
-
classmethod
-
class
FileArtifactReader¶ Bases:
altimeter.core.artifact_io.reader.ArtifactReaderArtifactReader to read from the filesystem
-
read_json(path)¶ Read a json artifact
- Parameters
path (
str) – filesystem path to artifact- Return type
Dict[str,Any]- Returns
artifact content
-
-
class
S3ArtifactReader¶ Bases:
altimeter.core.artifact_io.reader.ArtifactReaderArtifactReader to read from S3
-
read_json(path)¶ Read a json artifact
- Parameters
path (
str) – s3 uri to artifact. s3://bucket/key/path- Return type
Dict[str,Any]- Returns
artifact content
-
altimeter.core.artifact_io.writer module¶
Classes for ArtifactWriters. An ArtifactWriter writes a scan artifact dict to something - e.g. a file, s3 key, etc.
-
class
ArtifactWriter¶ Bases:
abc.ABCArtifactWriters write JSON artifacts to locations - e.g. s3, filesystem, etc.
-
classmethod
from_artifact_path(artifact_path, scan_id)¶ Create an ArtifactWriter based on an artifact path. This either returns a FileArtifactWriter or an S3ArtifactWriter depending on the value of artifact_path
- Return type
-
abstract
write_graph_set(name, graph_set, compression=None)¶ Write a graph artifact
- Parameters
name (
str) – namegraph_set (
ValidatedGraphSet) – ValidatedGraphSet object to write
- Return type
str- Returns
path to written artifact
-
abstract
write_json(name, data)¶ Write a json artifact
- Parameters
name (
str) – namedata (
BaseModel) – data
- Return type
str- Returns
path to written artifact
-
classmethod
-
class
FileArtifactWriter(scan_id, output_dir)¶ Bases:
altimeter.core.artifact_io.writer.ArtifactWriterArtifactWriter which writes to a file.
- Parameters
output_dir (
Path) – output filesystem dir
-
write_graph_set(name, graph_set, compression=None)¶ Write a graph artifact
- Parameters
name (
str) – namegraph_set (
ValidatedGraphSet) – ValidatedGraphSet object to write
- Return type
str- Returns
path to written artifact
-
write_json(name, data)¶ Write artifact data to self.output_dir/name.json
- Parameters
name (
str) – filenamedata (
BaseModel) – data
- Return type
str- Returns
Full filesystem path of artifact file
-
class
S3ArtifactWriter(bucket, key_prefix)¶ Bases:
altimeter.core.artifact_io.writer.ArtifactWriterArtifactWriter which writes to S3.
- Parameters
bucket (
str) – s3 bucketkey_prefix (
str) – s3 key prefix
-
write_graph_set(name, graph_set, compression=None)¶ Write a graph artifact
- Parameters
name (
str) – namegraph_set (
ValidatedGraphSet) – ValidatedGraphSet to write
- Return type
str- Returns
path to written artifact
-
write_json(name, data)¶ Write artifact data to s3://self.bucket/self.key_prefix/name.json
- Parameters
name (
str) – s3 key namedata (
BaseModel) – data
- Returns
//bucket/key/path) to artifact
- Return type
S3 uri (s3