Michael Hadorn
09/28/2022, 5:48 AMRob Freedy
09/28/2022, 12:46 PMMichael Hadorn
09/29/2022, 5:11 AMimport asyncio
from prefect.client import get_client
from prefect.settings import PREFECT_API_URL, temporary_settings
from blocks.my_config import MyConfig
async def do_work():
# this loades the cloud client (defined via active profile -> PREFECT_API_URL)
client_cloud = get_client()
my_config_block = await client_cloud.read_block_document_by_name('dev', block_type_slug='my-config')
# switch to local instance: will set PREFECT_API_URL to empty
with temporary_settings(restore_defaults={PREFECT_API_URL}):
# everything here will be done in local instance.
new_block = MyConfig(**my_config_block.data)
await new_block.save('dev', True)
if __name__ == "__main__":
asyncio.run(do_work())