https://prefect.io logo
Title
r

Robin Eklund

09/28/2022, 8:14 AM
Hi! Not sure if this is the right place for the question. But i am following this tutorial: https://docs.prefect.io/tutorials/deployments/ I have successfully reached the step where i create the deployment with this command:
prefect deployment build ./log_flow.py:log_flow -n log-simple -q test
which generate the yaml file. But it looks slightly different for
infrastructure
where in the tutorial they have:
infrastructure:
  type: process
  env: {}
  labels: {}
  name: null
  command:
  - python
  - -m
  - prefect.engine
  stream_output: true
and i have:
infrastructure:
  type: process
  env: {}
  labels: {}
  name: null
  command: null
  stream_output: true
  block_type_slug: process
  _block_type_slug: process
And when i run
prefect deployment apply log_flow-deployment.yaml
I get this error:
prefect.exceptions.PrefectHTTPStatusError: Client error '403 Forbidden' for url '<prefect_domain>/api/block_types/016c45c9-6346-49c1-a1cb-da3021f915b2'
Response: {'detail': 'protected block types cannot be updated.'}
For more information check: <https://httpstatuses.com/403>
An exception occurred.
Anyone knows what i need to do?
j

jpuris

09/28/2022, 8:34 AM
Can reproduce the difference in deployment manifest file. Have not run into the mentioned
Response: {'detail': 'protected block types cannot be updated.'}
when applying said manifest though 🤷
prefect build
2.4.2 would generate
prefect deployment build ./log_flow.py:log_flow -n log-simple -q test
###
### A complete description of a Prefect Deployment for flow 'log-flow'
###
name: log-simple
description: null
version: c2966c5bd40b38928108be01c093c08a
# The work queue that will handle this deployment's runs
work_queue_name: test
tags: []
parameters: {}
schedule: null
infra_overrides: {}
infrastructure:
  type: process
  env: {}
  labels: {}
  name: null
  command: null
  stream_output: true
  block_type_slug: process
  _block_type_slug: process

###
### DO NOT EDIT BELOW THIS LINE
###
flow_name: log-flow
manifest_path: null
storage: null
path: /Users/jp/projects/test
entrypoint: log_flow.py:log_flow
parameter_openapi_schema:
  title: Parameters
  type: object
  properties: {}
  required: null
  definitions: null
while prefect 2.0.1 would output
prefect deployment build ./log_flow.py:log_flow -n log-simple
###
### A complete description of a Prefect Deployment for flow 'log-flow'
###
name: log-simple
description: null
version: c2966c5bd40b38928108be01c093c08a
tags: []
parameters: {}
schedule: null
infra_overrides: {}
infrastructure:
  type: process
  env: {}
  labels: {}
  name: null
  command:
  - python
  - -m
  - prefect.engine
  stream_output: true
###
### DO NOT EDIT BELOW THIS LINE
###
flow_name: log-flow
manifest_path: null
storage: null
path: /Users/jp/projects/test
entrypoint: log_flow.py:log_flow
parameter_openapi_schema:
  title: Parameters
  type: object
  properties: {}
  required: null
  definitions: null
diff
❯ diff *yaml
6a7,8
> # The work queue that will handle this deployment's runs
> work_queue_name: test
16,19c18
<   command:
<   - python
<   - -m
<   - prefect.engine
---
>   command: null
20a20,22
>   block_type_slug: process
>   _block_type_slug: process
>
log_flow.py
❯ cat log_flow.py
from prefect import flow

@flow
def log_flow() -> None:
    print('Hello World!')

if __name__ == '__main__':
    log_flow()
d

Deepanshu Aggarwal

09/28/2022, 9:44 AM
i was facing a very similar issue few days back. i was using the wrong api url and key . please verify it once
j

jpuris

09/28/2022, 9:57 AM
logged into cloud or not does not make a difference in my test 🤷
r

Robin Eklund

09/28/2022, 11:24 AM
Thanks for your response! @Deepanshu Aggarwal the flow gets created so it should be the correct api URL? also for creating the flow, no key was needed
I didn't mention that but we have deployed Prefect 2 on AWS in EKS
j

jpuris

09/28/2022, 11:31 AM
@Robin Eklund just to be sure, are you applying the built deployment yaml to prefect 1 or 2? Are you able to reproduce this locally? If so, do you have a minimally reproducible example 🤔
r

Robin Eklund

09/28/2022, 11:42 AM
i am using the prefect cli
2.4.0
and applying the deployment to prefect 2
seems it is
2.4.2
, but i guess the minor version shouldn't matter?
I haven't seen this error locally before - this test i am doing atm. was to deploy a flow to self hosted prefect 2. Let me know if i can provide with any other information or if you would be up for a call
r

Rob Freedy

09/28/2022, 1:15 PM
Are you able to run
prefect config view
and double check your api key and api url?
r

Robin Eklund

09/28/2022, 2:19 PM
prefect config view
PREFECT_PROFILE='default'
PREFECT_API_URL='<the_prefect_domain>/api' (from profile)
this is what i have and it seems to be correct, but i haven' generated any api key
r

Rob Freedy

09/28/2022, 2:38 PM
It looks like you may need to create and set an API Key to access blocks that were created in the UI. I would recommend looking into this documentation: https://docs.prefect.io/ui/cloud-getting-started/#create-an-api-key