EmptyDir
A sentinel :class:Dir representing 'no directory was produced'.
Use this as a return value when a task may or may not produce an output directory,
e.g. flyte.run_python_script when the user did not request output_dir::
@env.task
async def maybe_produce_dir(...) - > Output:
if user_wants_dir:
return Output(output_dir=await Dir.from_local(path))
return Output(output_dir=EmptyDir())
On the receiving side, the value comes back as a plain Dir with
:attr:Dir.is_empty set to True (the deserializer doesn't preserve the
EmptyDir subclass identity, but the sentinel path round-trips). Callers should
branch on dir.is_empty rather than ``isinstance(dir, EmptyDir)`.
This exists because Optional[Dir] cannot round-trip through Flyte's
DataclassTransformer — mashumaro strips the Optional and calls
Dir._deserialize(None) which fails. EmptyDir keeps the field type as
plain Dir so the round-trip works.
Constructor
Signature
def EmptyDir(
data: Any = null
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| data | Any = null | Arbitrary keyword arguments. |
Signature
def EmptyDir(
data: Any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| data | Any | Additional keyword arguments to pass to the base Dir constructor. The 'path' key will be overridden to the empty directory sentinel, and 'name' will default to an empty string if not provided. |