bumpy-match-83743
07/27/2024, 2:35 PMancient-wolf-19325
07/27/2024, 2:35 PMBinary
type, which is a simple byte array with a tag to help different parts of the system communicate about what is in the byte array. Here is an example of how you can use the Binary
type in a Java `SdkRunnableTask`:
import org.flyte.flytekit.SdkRunnableTask;
import org.flyte.flytekit.SdkTypes;
import org.flyte.flytekit.SdkWorkflow;
import org.flyte.flytekit.SdkWorkflowBuilder;
import org.flyte.flytekit.core.Literal;
import org.flyte.flytekit.core.LiteralType;
import org.flyte.flytekit.core.Scalar;
import org.flyte.flytekit.core.Binary;
import java.util.List;
public class MyBinaryTask extends SdkRunnableTask<byte[], byte[]> {
public MyBinaryTask() {
super(SdkTypes.binary(), SdkTypes.binary());
}
@Override
public byte[] run(byte[] input) {
// Process the binary input and return a binary output
return processBinaryData(input);
}
private byte[] processBinaryData(byte[] input) {
// Example processing: simply return the input for demonstration
return input;
}
@Override
public List<String> getCustomJavaToolOptions() {
return List.of("-CustomJavaProperty");
}
public static void main(String[] args) {
SdkWorkflow workflow = new SdkWorkflow() {
@Override
public void expand(SdkWorkflowBuilder builder) {
byte[] inputData = new byte[]{0x01, 0x02, 0x03};
MyBinaryTask task = new MyBinaryTask();
builder.addTask("binaryTask", task, inputData);
}
};
workflow.run();
}
}
In this example:
1. Define the Task: MyBinaryTask
extends SdkRunnableTask
with input and output types as byte[]
.
2. Process Binary Data: The run
method processes the binary input and returns a binary output.
3. Workflow: A simple workflow is defined to run the task with binary input data.
Sources:
- https://github.com/flyteorg/flyte/issues/1363
- https://github.com/flyteorg/flyte/issues/1009
Note: I wasn’t able to find highly relevant data sources, but above are a few potentially relevant links. 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.