def deploy(self, project_name: str, build: bool = True, set_schedule_active: bool = True, **kwargs: Any) -> str: """ Deploy the flow to Prefect Cloud; if no storage is present on the Flow, the default value from your config will be used and initialized with `**kwargs`. Args: - project_name (str): the project that should contain this flow. - build (bool, optional): if `True`, the flow's environment is built prior to serialization; defaults to `True` - set_schedule_active (bool, optional): if `False`, will set the schedule to inactive in the database to prevent auto-scheduling runs (if the Flow has a schedule). Defaults to `True`. This can be changed later. - **kwargs (Any): if instantiating a Storage object from default settings, these keyword arguments will be passed to the initialization method of the default Storage class Returns: - str: the ID of the flow that was deployed """ if self.storage is None: self.storage = get_default_storage_class()(**kwargs) client = prefect.Client() deployed_flow = client.deploy( flow=self, build=build, project_name=project_name, set_schedule_active=set_schedule_active, ) return deployed_flow
def test_default_storage_ignores_bad_config(): with utilities.configuration.set_temporary_config( {"flows.defaults.storage.default_class": "FOOBAR"} ): with pytest.warns(UserWarning): assert storage.get_default_storage_class() is storage.Docker
def deploy(self, project_name: str, build: bool = True, labels: List[str] = None, set_schedule_active: bool = True, version_group_id: str = None, **kwargs: Any) -> str: """ Deploy the flow to Prefect Cloud; if no storage is present on the Flow, the default value from your config will be used and initialized with `**kwargs`. Args: - project_name (str): the project that should contain this flow. - build (bool, optional): if `True`, the flow's environment is built prior to serialization; defaults to `True` - labels (List[str], optional): a list of labels to add to this Flow's environment; useful for associating Flows with individual Agents; see http://docs.prefect.io/cloud/agent/overview.html#flow-affinity-labels - set_schedule_active (bool, optional): if `False`, will set the schedule to inactive in the database to prevent auto-scheduling runs (if the Flow has a schedule). Defaults to `True`. This can be changed later. - version_group_id (str, optional): the UUID version group ID to use for versioning this Flow in Cloud; if not provided, the version group ID associated with this Flow's project and name will be used. - **kwargs (Any): if instantiating a Storage object from default settings, these keyword arguments will be passed to the initialization method of the default Storage class Returns: - str: the ID of the flow that was deployed """ if self.storage is None: self.storage = get_default_storage_class()(**kwargs) if isinstance(self.storage, prefect.environments.storage.Local): self.environment.labels.add("local") self.environment.labels.add(slugify(self.name)) if labels: self.environment.labels.update(labels) client = prefect.Client() deployed_flow = client.deploy( flow=self, build=build, project_name=project_name, set_schedule_active=set_schedule_active, version_group_id=version_group_id, ) return deployed_flow
def test_default_storage(): assert storage.get_default_storage_class() is storage.Local
def test_default_storage_responds_to_config(): with utilities.configuration.set_temporary_config({ "flows.defaults.storage.default_class": "prefect.environments.storage.Memory" }): assert storage.get_default_storage_class() is storage.Memory