#180 Fix deployment versioning with environment and image cache hash
Pull request opened by
pingsutw
## Summary
• Fixed deployment versioning to include environment and image cache hashes in version calculation
• Added hashlib and cloudpickle imports for proper hash computation
• Updated version calculation logic to compute MD5 hash from deployment environments, code bundle version, and image cache when no explicit version is provided
## Test plan
import os
import flyte
# TaskEnvironments provide a simple way of grouping configuration used by tasks (more later).
env = flyte.TaskEnvironment(name="hello_world", resources=flyte.Resources(memory="250Mi"), image=os.getenv("FLYTE_IMAGE"))
# use TaskEnvironments to define tasks, which are regular Python functions.
@env.task
def fn(x: int) -> int: # type annotations are recommended.
slope, intercept = 2, 5
return slope * x + intercept
# tasks can also call other tasks, which will be manifested in different containers.
@env.task
def main(x_list: list[int]) -> float:
x_len = len(x_list)
if x_len < 10:
raise ValueError(f"x_list doesn't have a larger enough sample size, found: {x_len}")
y_list = list(flyte.map(fn, x_list)) # flyte.map is like Python map, but runs in parallel.
y_mean = sum(y_list) / len(y_list)
return y_mean
if
name == "__main__":
flyte.init_from_config() # establish remote connection from within your script.
run = flyte.run(main, x_list=list(range(10))) # run remotely inline and pass data.
# print various attributes of the run.
print(run.name)
print(run.url)
run.wait(run) # stream the logs from the root action to the terminal.
flyteorg/flyte-sdk