Skip to main content
Version: 0.83.13

Directory

The Directory constructor creates a Directory object that represents a directory inside an existing service (see the ServiceConfig object). Directory object can be either a files artifact or a persistent directory, depending on the arguments passed to the constructor.

file_artifact_directory = Directory(
artifact_name=files_artifact_1,
)
# Or:
persistent_directory = Directory(
persistent_key="data-directory"
)

A directory composed of a files artifact will be automatically provisioned with the given files artifact content. In the above example, files_artifact_1 is a files artifact name. (see upload_files, render_templates and store_service_files to learn more about on how to create file artifacts).

A persistent directory, as its name indicates, persists over service updates and restarts. It is uniquely identified by its persistent_key and the service ID on which it is being used (a persistent directory cannot be shared across multiple services). When it is first created, it will be empty. The service can write anything in it. When the service gets updated, the data in it persists. It is particularly useful for a service's data directory, logs directory, etc.