Bases: Packager
This packager stores the flow as a single file.
By default, the file is the source code of the module the flow is defined in.
Alternative serialization modes are available in prefect.packaging.serializers
.
Source code in prefect/packaging/file.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 | class FilePackager(Packager):
"""
This packager stores the flow as a single file.
By default, the file is the source code of the module the flow is defined in.
Alternative serialization modes are available in `prefect.packaging.serializers`.
"""
type: Literal["file"] = "file"
serializer: Serializer = Field(default_factory=SourceSerializer)
filesystem: WritableFileSystem = Field(
default_factory=lambda: LocalFileSystem(
basepath=PREFECT_HOME.value() / "storage"
)
)
@inject_client
async def package(self, flow: Flow, client: "PrefectClient") -> FilePackageManifest:
content = self.serializer.dumps(flow)
key = stable_hash(content)
await self.filesystem.write_path(key, content)
filesystem_id = (
self.filesystem._block_document_id
or await self.filesystem._save(is_anonymous=True)
)
return self.base_manifest(flow).finalize(
serializer=self.serializer,
filesystem_id=filesystem_id,
key=key,
)
|