File Parameters
Copyright (C) 2023 Cadence Design Systems, Inc. (Cadence)
- class orionplatform.parameters.files.FileInputParameter(name: str | None = None, title: str | None = None, default=None, null: bool = False, help_text: str = '', promoted: bool = False, promoted_name: str | None = None, required: bool = False, hidden: bool = False, value=None, static: bool = False, max_value=None, min_value=None, max_length=None, choices=None, level='basic', description: str = '', many: bool = False, order: int | None = None)
Bases:
floe.api.parameters.BaseParameter
FileInputParameter can be a single file IDENTIFIER, or a dictionary.
IDENTIFIER
or
{"file": INT_ID}
or
{SOURCE: [{ID_TYPE: IDENTIFIER}]}
Parameters:
INT_ID an integer IDENTIFIER an integer, or a path for a local file SOURCE "files" ID_TYPE "id" if in Orion, or "path" if local
Example - single Orion file:
{ "file": 135 }
Example - multiple Orion files:
{ "files": [ { "id": 135, }, { "id": 136, } ], }
Example - multiple local files:
{ "files": [ { "path": "100.oedb", }, { "path": "1000.oedb", } ], }
Example - mix of local files and Orion files:
{ "files": [ { "path": "100.oedb", }, { "id": 814, }, ] }
- Returns:
orionplatform.parameters.FileStream
FileStream
can be used as an iterator to get the files specified by the parameter. It can also be used to iterate over byte chunks of those filesPython Example Emit Files
from floe.api.cubes import SourceCube from orionplatform.parameters import FileInputParameter class ExampleCube(ComputeCube): data_in = FileInputParameter("data_in") def begin(self): for file in self.args.data_in: self.log.info("Initialized with file {} {}, is_local={}", file.identifier, file.name, file.is_local)
Python Example Emit Bytes
from floe.api.cubes import SourceCube from floe.api.ports import BinaryOutputPort from orionplatform.parameters import FileInputParameter class ExampleCube(SourceCube): success = BinaryOutputPort("success") data_in = FileInputParameter("data_in") def __iter__(self): for chunk in self.args.data_in.chunks(): self.log.info("Outputting binary chunk") yield chunk
- class orionplatform.parameters.files.FileOutputParameter(name: str | None = None, title: str | None = None, default=None, null: bool = False, help_text: str = '', promoted: bool = False, promoted_name: str | None = None, required: bool = False, hidden: bool = False, value=None, static: bool = False, max_value=None, min_value=None, max_length=None, choices=None, level='basic', description: str = '', many: bool = False, order: int | None = None)
Bases:
floe.api.parameters.BaseParameter
Parameter used to specify the name of a File created within a Cube
- class orionplatform.parameters.files.FileStream(obj, session=None, required=False, fieldlist: List[str] | None = None)
Provides an iterator of wrappers around Files that provide the following utility:
identifier (property): either the Orion Id or local path
name (property): base name of the file
is_local (property): true if is reading from local file
read(): returns bytes of file
copy_to(filename): Copy to a local file
FileStream is tightly coupled to
FileInputParameter
and is not intended to be used separately.- chunks()
Method which yields chunks for all files in the stream.