Skip to content

Commit

Permalink
add types to functions.py
Browse files Browse the repository at this point in the history
  • Loading branch information
savarin committed Feb 12, 2024
1 parent ccfc902 commit 16ed523
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions modal/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Optional,
Sequence,
Set,
Sized,
Type,
Union,
)
Expand Down Expand Up @@ -82,7 +83,7 @@
from .secret import _Secret
from .volume import _Volume

OUTPUTS_TIMEOUT = 55 # seconds
OUTPUTS_TIMEOUT = 55.0 # seconds
ATTEMPT_TIMEOUT_GRACE_PERIOD = 5 # seconds


Expand Down Expand Up @@ -563,13 +564,13 @@ def from_args(
stub,
image=None,
secret: Optional[_Secret] = None,
secrets: Collection[_Secret] = (),
secrets: Sequence[_Secret] = (),
schedule: Optional[Schedule] = None,
is_generator=False,
gpu: GPU_T = None,
# TODO: maybe break this out into a separate decorator for notebooks.
mounts: Collection[_Mount] = (),
network_file_systems: Dict[Union[str, os.PathLike], _NetworkFileSystem] = {},
network_file_systems: Dict[Union[str, PurePosixPath], _NetworkFileSystem] = {},
allow_cross_region_volumes: bool = False,
volumes: Dict[Union[str, os.PathLike], Union[_Volume, _S3Mount]] = {},
webhook_config: Optional[api_pb2.WebhookConfig] = None,
Expand Down Expand Up @@ -924,7 +925,7 @@ def from_parametrized(
obj,
from_other_workspace: bool,
options: Optional[api_pb2.FunctionOptions],
args: Iterable[Any],
args: Sized,
kwargs: Dict[str, Any],
) -> "_Function":
async def _load(provider: _Function, resolver: Resolver, existing_object_id: Optional[str]):
Expand Down Expand Up @@ -1260,7 +1261,7 @@ async def remote_gen(self, *args, **kwargs) -> AsyncGenerator[Any, None]:
async for item in self._call_generator(args, kwargs): # type: ignore
yield item

def call(self, *args, **kwargs) -> Awaitable[Any]:
def call(self, *args, **kwargs) -> Awaitable[Any]: # type: ignore[return]
"""Deprecated. Use `f.remote` or `f.remote_gen` instead."""
# TODO: Generics/TypeVars
if self._is_generator:
Expand Down Expand Up @@ -1386,7 +1387,7 @@ async def get_current_stats(self) -> FunctionStats:
Function = synchronize_api(_Function)


class _FunctionCall(_Object, type_prefix="fc"):
class _FunctionCall(_Object, type_prefix="fc"): # type: ignore[call-arg]
"""A reference to an executed function call.
Constructed using `.spawn(...)` on a Modal function with the same
Expand Down Expand Up @@ -1460,8 +1461,8 @@ async def _gather(*function_calls: _FunctionCall):
gather = synchronize_api(_gather)


_current_input_id = ContextVar("_current_input_id")
_current_function_call_id = ContextVar("_current_function_call_id")
_current_input_id: ContextVar = ContextVar("_current_input_id")
_current_function_call_id: ContextVar = ContextVar("_current_function_call_id")


def current_input_id() -> Optional[str]:
Expand Down

0 comments on commit 16ed523

Please sign in to comment.