fused
Advanced tools
+1
-1
@@ -285,3 +285,3 @@ import asyncio | ||
| if instance_type is None and resolved_udf.storage_type == "local_job_step": | ||
| instance_type = resolved_udf.udf.instance_type | ||
| instance_type = resolved_udf.udf.engine | ||
@@ -288,0 +288,0 @@ if disk_size_gb is None and resolved_udf.storage_type == "local_job_step": |
@@ -36,2 +36,3 @@ import ast | ||
| "engine", | ||
| "instance_type", | ||
| "cache_max_age", | ||
@@ -117,2 +118,19 @@ "cache", | ||
| def _validate_engine(engine: Optional[str]) -> Optional[str]: | ||
| if engine is None: | ||
| return None | ||
| # Engine can be "local", "remote", "realtime", or a batch instance type | ||
| if engine in ["local", "remote", "realtime"]: | ||
| return engine | ||
| if engine not in WHITELISTED_INSTANCE_TYPES_values: | ||
| raise ValueError( | ||
| "Invalid engine specified. Must be 'local', 'remote', 'realtime', or one of the whitelisted instance types " | ||
| f"({WHITELISTED_INSTANCE_TYPES_values})." | ||
| ) | ||
| return engine | ||
| def _validate_instance_type(instance_type: Optional[str]) -> Optional[str]: | ||
@@ -122,2 +140,10 @@ if instance_type is None: | ||
| warnings.warn( | ||
| FusedUdfWarning( | ||
| "The 'instance_type' parameter is deprecated. Use 'engine' instead. " | ||
| "Example: @fused.udf(engine='small') instead of @fused.udf(instance_type='small')" | ||
| ), | ||
| stacklevel=3, | ||
| ) | ||
| if ( | ||
@@ -136,3 +162,3 @@ instance_type != "realtime" | ||
| def _validate_disk_size_gb( | ||
| disk_size_gb: Optional[int], instance_type: Optional[str] | ||
| disk_size_gb: Optional[int], engine: Optional[str] | ||
| ) -> Optional[int]: | ||
@@ -142,3 +168,3 @@ if disk_size_gb is None: | ||
| if instance_type is None or instance_type == "realtime": | ||
| if engine is None or engine in ("realtime", "local", "remote"): | ||
| raise ValueError("disk_size_gb can only be specified for batch instance types.") | ||
@@ -162,2 +188,3 @@ | ||
| cache_max_age: Optional[str] = None, | ||
| engine: Optional[str] = None, | ||
| instance_type: Optional[str] = None, | ||
@@ -211,2 +238,12 @@ disk_size_gb: Optional[int] = None, | ||
| validated_engine = _validate_engine(engine) | ||
| validated_instance_type = _validate_instance_type(instance_type) | ||
| if validated_engine and validated_instance_type: | ||
| raise ValueError( | ||
| "Cannot specify both engine and instance_type. Specify only engine." | ||
| ) | ||
| final_engine = validated_engine or validated_instance_type | ||
| new_udf = _udf_cls( | ||
@@ -217,4 +254,4 @@ code=src.strip("\n"), | ||
| cache_max_age=_parse_cache_max_age(cache_max_age), | ||
| instance_type=_validate_instance_type(instance_type), | ||
| disk_size_gb=_validate_disk_size_gb(disk_size_gb, instance_type), | ||
| engine=final_engine, | ||
| disk_size_gb=_validate_disk_size_gb(disk_size_gb, final_engine), | ||
| region=region, | ||
@@ -245,2 +282,3 @@ parameters=default_parameters or {}, | ||
| cache_max_age: Optional[str] = None, | ||
| engine: Optional[str] = None, | ||
| instance_type: Optional[str] = None, | ||
@@ -257,5 +295,5 @@ disk_size_gb: Optional[int] = None, | ||
| cache_max_age: The maximum age when returning a result from the cache. | ||
| instance_type: The type of instance to use for remote execution ('realtime', | ||
| or 'small', 'medium', 'large' or one of the whitelisted instance types). | ||
| If not specified (and also not specified in `fused.run()`, defaults | ||
| engine: The execution engine to use ('remote', 'local', 'realtime', or a batch | ||
| instance type like 'small', 'medium', 'large', 'm5.large', etc.). | ||
| If not specified (and also not specified in `fused.run()`), defaults | ||
| to 'realtime'. | ||
@@ -291,2 +329,12 @@ disk_size_gb: The size of the disk in GB to use for remote execution | ||
| ``` | ||
| To create a UDF that runs on a specific instance type: | ||
| ```py | ||
| @fused.udf(engine='large') | ||
| def udf(bbox): | ||
| # This will run on a large batch instance | ||
| ... | ||
| return result | ||
| ``` | ||
| """ | ||
@@ -299,2 +347,3 @@ return _udf_internal( | ||
| cache_max_age=cache_max_age, | ||
| engine=engine, | ||
| instance_type=instance_type, | ||
@@ -301,0 +350,0 @@ disk_size_gb=disk_size_gb, |
@@ -1,1 +0,1 @@ | ||
| __version__ = "2.0.0" | ||
| __version__ = "2.0.1" |
@@ -79,4 +79,4 @@ from __future__ import annotations | ||
| instance_type: str | None = None | ||
| """The instance type to run this UDF on by default, if not specified in | ||
| engine: str | None = None | ||
| """The engine to run this UDF on by default, if not specified in | ||
| `fused.run()`, e.g., "small"/"medium"/"large". | ||
@@ -83,0 +83,0 @@ """ |
+1
-1
| Metadata-Version: 2.4 | ||
| Name: fused | ||
| Version: 2.0.0 | ||
| Version: 2.0.1 | ||
| Project-URL: Homepage, https://www.fused.io | ||
@@ -5,0 +5,0 @@ Project-URL: Documentation, https://docs.fused.io |
Sorry, the diff of this file is too big to display
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
940830
0.27%22539
0.29%