bumpy-match-83743
07/29/2024, 8:46 PMflytekit-java
example of how to use the Binary data type?ancient-wolf-19325
07/29/2024, 8:47 PMflytekit-java
? If this doesn't help, please reach out to the Flyte support team for further assistance. 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.bumpy-match-83743
07/29/2024, 9:00 PMancient-wolf-19325
07/29/2024, 9:00 PMbumpy-match-83743
07/29/2024, 9:03 PMancient-wolf-19325
07/29/2024, 9:03 PMflytekit-java
. However, I can provide a general outline based on the Flyte documentation and the typical usage of Blob types in Flyte.
In Flyte, a Blob is used to refer to offloaded sets of files, typically stored in a cloud storage service like S3. The Blob type encapsulates the type of the store and a unique URI for where the data is stored.
Here is a general outline of how you might define and use a Blob type in a Flyte task using Java:
1. Define the Blob Type: You need to define the Blob type with its dimensionality (SINGLE or MULTIPART) and format (e.g., "csv", "parquet").
2. Create a Task: Define a Flyte task that takes a Blob as input and/or output.
3. Workflow: Define a workflow that uses the task.
Here is a conceptual example:
import org.flyte.flytekit.SdkTypes;
import org.flyte.flytekit.SdkWorkflow;
import org.flyte.flytekit.SdkWorkflowBuilder;
import org.flyte.flytekit.SdkRunnableTask;
import org.flyte.flytekit.SdkBindingData;
import org.flyte.flytekit.SdkLiteralTypes;
import org.flyte.flytekit.SdkWorkflowInput;
import org.flyte.flytekit.SdkWorkflowOutput;
import org.flyte.flytekit.SdkTypes.SdkType;
import org.flyte.flytekit.SdkTypes.SdkLiteralType;
import org.flyte.flytekit.SdkTypes.SdkLiteralType.BlobType;
import org.flyte.flytekit.SdkTypes.SdkLiteralType.BlobType.BlobDimensionality;
import java.util.Map;
public class BlobExample {
public static class BlobTask extends SdkRunnableTask<Map<String, SdkBindingData>, Map<String, SdkBindingData>> {
public BlobTask() {
super(SdkTypes.mapOf(SdkLiteralTypes.STRING, SdkLiteralTypes.BLOB), SdkTypes.mapOf(SdkLiteralTypes.STRING, SdkLiteralTypes.BLOB));
}
@Override
public Map<String, SdkBindingData> run(Map<String, SdkBindingData> input) {
// Your task logic here
// For example, read the blob from the input, process it, and return a new blob
return input;
}
}
public static class BlobWorkflow extends SdkWorkflow {
@Override
public void expand(SdkWorkflowBuilder builder) {
SdkWorkflowInput<SdkBindingData> input = builder.inputOfType(SdkLiteralTypes.BLOB, "input_blob");
SdkWorkflowOutput<SdkBindingData> output = builder.outputOfType(SdkLiteralTypes.BLOB, "output_blob");
BlobTask blobTask = new BlobTask();
SdkBindingData taskOutput = builder.apply("blob_task", blobTask, Map.of("input_blob", input)).get("output_blob");
builder.output("output_blob", taskOutput);
}
}
public static void main(String[] args) {
BlobWorkflow workflow = new BlobWorkflow();
// Execute the workflow
}
}
In this example:
- BlobTask
is a task that takes a Blob as input and produces a Blob as output.
- BlobWorkflow
is a workflow that uses the BlobTask
.ancient-wolf-19325
07/29/2024, 9:03 PMbumpy-match-83743
07/29/2024, 9:43 PM