Billy McMonagle
08/02/2022, 9:25 PMfrom prefect.infrastructure.kubernetes import KubernetesJob
kubernetes_job = KubernetesJob(
env={"HELLO": "WORLD"},
name="my-custom-kubernetes-job",
image="prefecthq/prefect:2.0.1-python3.9",
service_account_name="my-service-account",
image_pull_policy="IfNotPresent",
)
I am trying to register it as follows:
❯ prefect block register -f block.py
Successfully registered 1 block
┏━━━━━━━━━━━━━━━━━━━┓
┃ Registered Blocks ┃
┡━━━━━━━━━━━━━━━━━━━┩
│ Kubernetes Job │
└───────────────────┘
To configure the newly registered blocks, go to the Blocks page in the Prefect UI.
However, when I go to the Prefect UI, I don't see the new block. I have checked and I am correctly logged into the expected workspace.
Is this expected behavior, or am I doing something wrong? Thanks!Andrew Huang
08/02/2022, 9:40 PMfrom prefect.infrastructure.kubernetes import KubernetesJob
kubernetes_job = KubernetesJob(
env={"HELLO": "WORLD"},
name="my-custom-kubernetes-job",
image="prefecthq/prefect:2.0.1-python3.9",
service_account_name="my-service-account",
image_pull_policy="IfNotPresent",
)
kubernetes_job.save("my_kubernetes_job_name")
See:
https://orion-docs.prefect.io/concepts/blocks/#saving-blocksBilly McMonagle
08/02/2022, 9:44 PMKubernetesJob
inherits from Block. Looks like no CLI commands needed.Andrew Huang
08/02/2022, 9:46 PMBilly McMonagle
08/02/2022, 9:46 PMKubernetesJob
directly to a flow, but must first save the block and then reference it in a deployment build
command?Andrew Huang
08/02/2022, 9:57 PM.load()
recreates the base object, so I think theoretically you can use it directly in the flowfrom prefect.blocks.system import JSON
json_block = JSON(value={"the_answer": 42})
json_block.save(name="life-the-universe-everything")
loaded_json_block = json_block.load("life-the-universe-everything")
assert json_block == loaded_json_block
Billy McMonagle
08/02/2022, 9:59 PM