melodic-mechanic-59879
03/12/2025, 11:26 PMjolly-florist-66728
03/12/2025, 11:26 PMmelodic-mechanic-59879
03/12/2025, 11:29 PMmelodic-mechanic-59879
03/12/2025, 11:29 PMjolly-florist-66728
03/12/2025, 11:29 PMfrom flytekit import task, workflow
import torch
@task
def save_model_locally(model, local_path: str) -> str:
torch.save(model.state_dict(), local_path)
return local_path
@workflow
def model_workflow() -> str:
model = ... # Your model initialization
local_path = "/path/to/local/directory/model.pth"
return save_model_locally(model=model, local_path=local_path)
This code saves the model to a specified local directory. Would you like more details on this process or any other aspect of Flyte?
Sources:
- https://github.com/flyteorg/flytekit/blob/master/tests/flytekit/unit/core/test_local_raw_container.py
- https://github.com/flyteorg/flytesnacks/blob/master/examples/kfpytorch_plugin/kfpytorch_plugin/pytorch_lightning_mnist_autoencoder.py 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.