Bryan
10/24/2023, 4:48 AMfrom prefect import flow
from prefect_aws.secrets_manager import AwsSecret
secret_manager = AwsSecret.load(name="my-secret")
@flow(log_prints=True)
def example_read_secret():
print(secret_manager.read_secret())
example_read_secret()
The secret content is in JSON format but yet I get an error when I try to print the output of KeyError: 'SecretBinary'
Has anyone experienced this or know what could be wrong?Bryan
10/24/2023, 5:16 AMSecretBinary
The decrypted secret value, if the secret value was originally provided as binary data in the form of a byte array. The response parameter represents the binary data as a base64-encoded string.
If the secret was created by using the Secrets Manager console, or if the secret value was originally provided as a string, then this field is omitted. The secret value appears in SecretString instead.
Type: Base64-encoded binary data object
Length Constraints: Minimum length of 1. Maximum length of 65536.
In our case, our secret value was created in the AWS console, which would mean what should be returned is the SecretString and not the SecretBinary.
The example in the Boto3 documentation spells out this logic. https://boto3.amazonaws.com/v1/documentation/api/latest/guide/secrets-manager.html#example
Does this seem accurate to others?Bryan
10/24/2023, 5:37 AMNate
10/24/2023, 7:22 PMBryan
10/24/2023, 7:25 PMNate
10/24/2023, 7:35 PMBryan
10/24/2023, 7:42 PMNate
10/24/2023, 7:44 PMpydantic<2
in your project, but if you could share your trace you get that would be appreciatedBryan
10/24/2023, 7:45 PMNate
10/24/2023, 7:46 PMBryan
10/24/2023, 7:46 PMVu
10/26/2023, 5:03 PMBryan
10/28/2023, 12:12 AMBryan
10/31/2023, 5:41 AMNate
10/31/2023, 2:15 PMBryan
11/21/2023, 6:34 PMFlow could not be retrieved from deployment.
Traceback (most recent call last):
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/opt/prefect/dw_prefect_hubspot-dev/hubspot_pipeline.py", line 2, in <module>
from prefect_fivetran import FivetranCredentials
File "/usr/local/lib/python3.10/site-packages/prefect_fivetran/__init__.py", line 2, in <module>
from .credentials import FivetranCredentials
File "/usr/local/lib/python3.10/site-packages/prefect_fivetran/credentials.py", line 8, in <module>
class FivetranCredentials(Block):
File "/usr/local/lib/python3.10/site-packages/pydantic/v1/main.py", line 197, in __new__
File "/usr/local/lib/python3.10/site-packages/pydantic/v1/fields.py", line 506, in infer
File "/usr/local/lib/python3.10/site-packages/pydantic/v1/fields.py", line 436, in __init__
File "/usr/local/lib/python3.10/site-packages/pydantic/v1/fields.py", line 557, in prepare
File "/usr/local/lib/python3.10/site-packages/pydantic/v1/fields.py", line 831, in populate_validators
File "/usr/local/lib/python3.10/site-packages/pydantic/v1/validators.py", line 765, in find_validators
RuntimeError: no validator found for <class 'pydantic.types.SecretStr'>, see `arbitrary_types_allowed` in Config
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 406, in retrieve_flow_then_begin_flow_run
flow = await load_flow_from_flow_run(flow_run, client=client)
File "/usr/local/lib/python3.10/site-packages/prefect/client/utilities.py", line 51, in with_injected_client
return await fn(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/prefect/deployments/deployments.py", line 254, in load_flow_from_flow_run
flow = await run_sync_in_worker_thread(load_flow_from_entrypoint, str(import_path))
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/asyncutils.py", line 91, in run_sync_in_worker_thread
return await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/usr/local/lib/python3.10/site-packages/prefect/flows.py", line 1498, in load_flow_from_entrypoint
flow = import_object(entrypoint)
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 201, in import_object
module = load_script_as_module(script_path)
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 164, in load_script_as_module
raise ScriptError(user_exc=exc, path=path) from exc
prefect.exceptions.ScriptError: Script at 'hubspot_pipeline.py' encountered an exception: RuntimeError("no validator found for <class 'pydantic.types.SecretStr'>, see `arbitrary_types_allowed` in Config")
I have upgrade to prefect 2.14.4 and my deployment looks like what I have below if that helps at all:
deployments:
- name: dev-deployment
version:
tags: []
description: ECS-Push Deployment
schedule:
entrypoint: .\main.py:someflow
parameters: {}
pull:
- prefect.deployments.steps.git_clone:
id: clone-step
repository: <https://github.com/my-repos/some-repo.git>
branch: "dev"
credentials: "{{ prefect.blocks.github-credentials.github-creds }}"
- prefect.deployments.steps.pip_install_requirements:
directory: "{{ clone-step.directory }}"
requirements_file: requirements.txt
work_pool:
name: Ecs-push
work_queue_name:
job_variables: {}
The only thing I can think of is that the default ECS image being used (Note: I am specifying one therefore using the default), has some conflicting modules or modules that are superseding what's in my requirements.txt. Any thoughts?Nate
11/21/2023, 8:40 PMNate
11/21/2023, 8:41 PMprefect-fivetran
collection as fivetran owns the repo
i took a quick look at the code and its a pretty simple http client that honestly would be really easy to rip out and use as desired if you didnt want the overhead of installing the collection / dealing with their pinsBryan
11/21/2023, 8:50 PMprefect
prefect-aws
prefect-fivetran
prefect-dbt
Where ever pydantic is getting installed it's not by me explicitlyNate
11/21/2023, 8:50 PMpydantic<2
in your reqs fileBryan
11/21/2023, 8:51 PMBryan
11/21/2023, 8:56 PMBryan
11/21/2023, 8:59 PMNate
11/21/2023, 9:11 PMNate
11/21/2023, 9:12 PMBryan
11/21/2023, 10:24 PMBryan
11/21/2023, 10:25 PMNate
11/21/2023, 11:37 PMBryan
11/21/2023, 11:39 PMNate
11/21/2023, 11:43 PMBryan
11/21/2023, 11:46 PMNate
11/21/2023, 11:51 PMBryan
11/21/2023, 11:53 PMNate
11/21/2023, 11:56 PMBryan
11/21/2023, 11:56 PMNate
11/22/2023, 12:00 AMNate
11/22/2023, 12:01 AMBryan
11/22/2023, 12:02 AMNate
11/22/2023, 12:03 AMNate
11/22/2023, 12:03 AMBryan
11/22/2023, 12:04 AMNate
11/22/2023, 12:04 AMBryan
11/22/2023, 12:05 AMNate
11/22/2023, 12:05 AMBryan
11/22/2023, 12:08 AMNate
11/22/2023, 12:11 AMBryan
11/22/2023, 12:11 AMNate
11/22/2023, 12:11 AMBryan
11/22/2023, 12:13 AMBryan
11/22/2023, 12:14 AM[
{
"prefect.deployments.steps.git_clone": {
"id": "clone-step",
"branch": "dev",
"repository": "<https://github.com/some_org/prefect_hubspot.git>",
"credentials": "{{ prefect.blocks.github-credentials.github-creds }}"
}
},
{
"prefect.deployments.steps.pip_install_requirements": {
"directory": "{{ clone-step.directory }}",
"requirements_file": "requirements.txt"
}
}
]
Nate
11/22/2023, 12:16 AMNate
11/22/2023, 12:16 AMBryan
11/22/2023, 12:19 AMNate
11/22/2023, 1:03 AMBryan
11/22/2023, 1:04 AMNate
11/22/2023, 1:04 AMBryan
11/22/2023, 1:04 AMBryan
11/28/2023, 1:30 AMJames
01/09/2024, 9:52 PMprefect
prefect-aws
prefect-fivetran
prefect-dbt
Our deployment just started getting the error `RuntimeError: no validator found for <class 'pydantic.types.SecretStr'>, see arbitrary_types_allowed
in Config` yesterdayBryan
01/09/2024, 9:59 PMJames
01/09/2024, 10:02 PMpydantic<2
is the key to fix it, though our deployment setup is a bit different and I have not yet found the right place to insert it that fixes the error. I will take a look and see if I can get it to workJames
01/09/2024, 10:05 PMBryan
01/09/2024, 10:08 PMBryan
01/09/2024, 10:11 PMJames
01/09/2024, 10:12 PMBryan
01/09/2024, 10:12 PMJames
01/09/2024, 11:43 PMFROM prefecthq/prefect:2.14.11-python3.10
...
RUN pip3 install prefect-fivetran
...
RUN pip3 install pydantic==1.10
Bryan
01/09/2024, 11:50 PMFROM prefecthq/prefect:2.14.6-python3.11
COPY . /opt/prefect/dw_prefect_project/
WORKDIR /opt/prefect/dw_prefect_project/
RUN pip install -r requirements.txt
James
01/09/2024, 11:52 PMprefect-fivetran
and pydantic
are in the right order in the requirements.txt
file, it works?Bryan
01/09/2024, 11:52 PMBryan
01/10/2024, 12:02 AMname: Prefect Deploy to Amazon ECS
on:
workflow_call:
env:
AWS_REGION: us-west-2 # This is our AWS region
ECR_REPO_NAME: <http://9999999999.dkr.ecr.us-west-2.amazonaws.com/${{|9999999999.dkr.ecr.us-west-2.amazonaws.com/${{> github.event.repository.name }} # Save the ECR Repo path/URL to be used in the prefect.yaml
GIT_REPO_NAME: ${{ github.event.repository.name }}
GIT_REPO_URL: ${{ github.server_url }}/${{ github.repository}}.git # Save the Git Repo URL to be used in the prefect.yaml file
GIT_REPO_BRANCH: ${{ github.ref_name }} # Save the Git Repo Branch to be used in the prefect.yaml file
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
# environment: development
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
with:
aws-access-key-id: ${{ secrets.GENDEV_DEPLOY_USER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.GENDEV_DEPLOY_USER_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a
- uses: int128/create-ecr-repository-action@v1
with:
repository: ${{ env.GIT_REPO_NAME }}
public: false
- name: Install Python Requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Set Prefect Workspace
env:
PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }}
PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }}
run: prefect cloud workspace set --workspace "workspace36-lesath/some-workspace"
- name: Prefect Deploy
env:
PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }}
PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }}
run: prefect deploy --name ${{ env.GIT_REPO_BRANCH }}-${{ env.GIT_REPO_NAME }}
James
01/10/2024, 8:21 PMprefecthq/prefect:2.13.4-python3.10
and then add pydantic==1.10.0
to the end of env.EXTRA_PIP_PACKAGES
--it seems like that becomes the final step in the build.
Note that we also had to add prefecthq/prefect:2.13.4-python3.10
and pydantic==1.10.0
to our deployment worker config too (based on the docs, this will override the configuration set elsewhere... so this step alone might be enough? It is a lot of configs to keep track of)Bryan
01/10/2024, 9:15 PMBryan
02/06/2024, 4:02 PMJames
02/06/2024, 4:49 PM