Matthew Jeffs
06/26/2024, 6:16 PMMarvin
06/26/2024, 6:17 PMsh
prefect variables set MY_VARIABLE '{"key": "value"}'
If you need further details or examples, feel free to ask!Matthew Jeffs
06/26/2024, 6:18 PMMarvin
06/26/2024, 6:18 PMjson
{
"key1": "value1",
"key2": {
"nestedKey": "nestedValue"
},
"key3": [1, 2, 3]
}
### Using Prefect CLI:
You can pass this JSON as a string when setting a variable via the Prefect CLI. For example:
sh
prefect variables set MY_VARIABLE '{"key1": "value1", "key2": {"nestedKey": "nestedValue"}, "key3": [1, 2, 3]}'
### Verify the Variable:
To verify that the variable is correctly set, you can use:
sh
prefect variables get MY_VARIABLE
This should print out:
json
{
"key1": "value1",
"key2": {
"nestedKey": "nestedValue"
},
"key3": [1, 2, 3]
}
Make sure your JSON is valid and correctly formatted to avoid pydantic errors. If you still encounter issues, consider verifying the JSON format using online JSON validators such as JSONLint.
If you have further questions or need additional assistance, feel free to ask!Nate
06/26/2024, 6:56 PMprefect version
show for you?Matthew Jeffs
06/26/2024, 9:37 PMVersion: 2.19.5
API version: 0.8.4
Python version: 3.11.9
Git commit: 538dc374
Built: Thu, Jun 13, 2024 2:50 PM
OS/Arch: linux/x86_64
Profile: prefect-cloud
Server type: cloud
Matthew Jeffs
06/26/2024, 9:40 PMMatthew Jeffs
06/26/2024, 9:46 PMpydantic.error_wrappers.ValidationError: 1 validation error for VariableUpdate
value
ensure this value has at most 255 characters (type=value_error.any_str.max_length; limit_value=255)
That limit I interpreted here: https://docs.prefect.io/latest/guides/variables/ to be for the name of the variable and not the value itself.Marvin
06/26/2024, 9:46 PM[a-z, 0-9]
) or underscores (_
). Spaces are not allowed.
- Variable Values: Must have less than or equal to 5000 characters.
The error you're encountering suggests that there might be another validation enforcing a stricter limit on the length of the variable values, specifically 255 characters, which contradicts the documentation. This could be a bug or a specific constraint in a particular Prefect version.
For further assistance and clarity, the best course of action would be:
1. Verify the Prefect Version: Ensure you are using the latest version of Prefect, as this issue might have been resolved in recent updates.
2. Report the Issue: If you're already on the latest version and the issue persists, consider reporting it on Prefect’s GitHub Issues.
### Additional Information
Here is the link to the relevant section in the Prefect documentation detailing the size constraints for variables.
If there's anything more I can assist you with, please let me know!Matthew Jeffs
06/26/2024, 9:47 PM