Skip to content

Commit 61420f2

Browse files
jonasblancJonas Blanc
andauthored
refactor: disallow python 3.9 for functions api (#2354)
Co-authored-by: Jonas Blanc <jonas.blanc@cognite.com>
1 parent 3423a78 commit 61420f2

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

cognite/client/_api/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def create(
246246
env_vars (dict[str, str] | None): Environment variables as key/value pairs. Keys can contain only letters, numbers or the underscore character. You can create at most 100 environment variables.
247247
cpu (float | None): Number of CPU cores per function. Allowed range and default value are given by the `limits endpoint. <https://developer.cognite.com/api#tag/Functions/operation/functionsLimits>`_, and None translates to the API default. On Azure, only the default value is used.
248248
memory (float | None): Memory per function measured in GB. Allowed range and default value are given by the `limits endpoint. <https://developer.cognite.com/api#tag/Functions/operation/functionsLimits>`_, and None translates to the API default. On Azure, only the default value is used.
249-
runtime (RunTime | None): The function runtime. Valid values are ["py39", "py310", "py311", "py312", `None`], and `None` translates to the API default which will change over time. The runtime "py312" resolves to the latest version of the Python 3.12 series.
249+
runtime (RunTime | None): The function runtime. Valid values are ["py310", "py311", "py312", `None`], and `None` translates to the API default which will change over time. The runtime "py312" resolves to the latest version of the Python 3.12 series.
250250
metadata (dict[str, str] | None): Metadata for the function as key/value pairs. Key & values can be at most 32, 512 characters long respectively. You can have at the most 16 key-value pairs, with a maximum size of 512 bytes.
251251
index_url (str | None): Index URL for Python Package Manager to use. Be aware of the intrinsic security implications of using the `index_url` option. `More information can be found on official docs, <https://docs.cognite.com/cdf/functions/#additional-arguments>`_
252252
extra_index_urls (list[str] | None): Extra Index URLs for Python Package Manager to use. Be aware of the intrinsic security implications of using the `extra_index_urls` option. `More information can be found on official docs, <https://docs.cognite.com/cdf/functions/#additional-arguments>`_

cognite/client/data_classes/functions.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
if TYPE_CHECKING:
2424
from cognite.client import CogniteClient
2525

26-
RunTime: TypeAlias = Literal["py39", "py310", "py311", "py312"]
26+
RunTime: TypeAlias = Literal["py310", "py311", "py312"]
2727
FunctionStatus: TypeAlias = Literal["Queued", "Deploying", "Ready", "Failed"]
2828
HANDLER_FILE_NAME = "handler.py"
2929

@@ -90,7 +90,7 @@ class FunctionCore(WriteableCogniteResource["FunctionWrite"], ABC):
9090
env_vars (dict[str, str] | None): User specified environment variables on the function ((key, value) pairs).
9191
cpu (float | None): Number of CPU cores per function. Allowed range and default value are given by the `limits endpoint. <https://developer.cognite.com/api#tag/Functions/operation/functionsLimits>`_, and None translates to the API default. On Azure, only the default value is used.
9292
memory (float | None): Memory per function measured in GB. Allowed range and default value are given by the `limits endpoint. <https://developer.cognite.com/api#tag/Functions/operation/functionsLimits>`_, and None translates to the API default. On Azure, only the default value is used.
93-
runtime (str | None): Runtime of the function. Allowed values are ["py39","py310", "py311", "py312"]. The runtime "py312" resolves to the latest version of the Python 3.12 series.
93+
runtime (RunTime | None): Runtime of the function. Allowed values are ["py310", "py311", "py312"]. The runtime "py312" resolves to the latest version of the Python 3.12 series.
9494
metadata (dict[str, str] | None): Metadata associated with a function as a set of key:value pairs.
9595
"""
9696

@@ -106,7 +106,7 @@ def __init__(
106106
env_vars: dict[str, str] | None = None,
107107
cpu: float | None = None,
108108
memory: float | None = None,
109-
runtime: str | None = None,
109+
runtime: RunTime | None = None,
110110
metadata: dict[str, str] | None = None,
111111
) -> None:
112112
# name/file_id are required when using the class to read,
@@ -124,7 +124,7 @@ def __init__(
124124
self.env_vars = env_vars
125125
self.cpu = cpu
126126
self.memory = memory
127-
self.runtime = runtime
127+
self.runtime: RunTime | None = runtime
128128
self.metadata = metadata
129129

130130

@@ -146,7 +146,7 @@ class Function(FunctionCore):
146146
env_vars (dict[str, str] | None): User specified environment variables on the function ((key, value) pairs).
147147
cpu (float | None): Number of CPU cores per function. Allowed range and default value are given by the `limits endpoint. <https://developer.cognite.com/api#tag/Functions/operation/functionsLimits>`_, and None translates to the API default. On Azure, only the default value is used.
148148
memory (float | None): Memory per function measured in GB. Allowed range and default value are given by the `limits endpoint. <https://developer.cognite.com/api#tag/Functions/operation/functionsLimits>`_, and None translates to the API default. On Azure, only the default value is used.
149-
runtime (str | None): Runtime of the function. Allowed values are ["py39","py310", "py311", "py312"]. The runtime "py312" resolves to the latest version of the Python 3.12 series.
149+
runtime (RunTime | None): Runtime of the function. Allowed values are ["py310", "py311", "py312"]. The runtime "py312" resolves to the latest version of the Python 3.12 series.
150150
runtime_version (str | None): The complete specification of the function runtime with major, minor and patch version numbers.
151151
metadata (dict[str, str] | None): Metadata associated with a function as a set of key:value pairs.
152152
error (dict | None): Dictionary with keys "message" and "trace", which is populated if deployment fails.
@@ -168,7 +168,7 @@ def __init__(
168168
env_vars: dict[str, str] | None = None,
169169
cpu: float | None = None,
170170
memory: float | None = None,
171-
runtime: str | None = None,
171+
runtime: RunTime | None = None,
172172
runtime_version: str | None = None,
173173
metadata: dict[str, str] | None = None,
174174
error: dict | None = None,
@@ -196,7 +196,7 @@ def __init__(
196196
self.id: int = id # type: ignore
197197
self.created_time: int = created_time # type: ignore
198198
self.status: str = status # type: ignore
199-
self.runtime_version = runtime_version
199+
self.runtime_version: str | None = runtime_version
200200
self.error = error
201201
self._cognite_client = cast("CogniteClient", cognite_client)
202202

@@ -215,7 +215,7 @@ def as_write(self) -> FunctionWrite:
215215
env_vars=self.env_vars,
216216
cpu=self.cpu,
217217
memory=self.memory,
218-
runtime=cast(RunTime, self.runtime),
218+
runtime=self.runtime,
219219
metadata=self.metadata,
220220
)
221221

@@ -310,7 +310,7 @@ class FunctionWrite(FunctionCore):
310310
env_vars (dict[str, str] | None): User specified environment variables on the function ((key, value) pairs).
311311
cpu (float | None): Number of CPU cores per function. Allowed range and default value are given by the `limits endpoint. <https://developer.cognite.com/api#tag/Functions/operation/functionsLimits>`_, and None translates to the API default. On Azure, only the default value is used.
312312
memory (float | None): Memory per function measured in GB. Allowed range and default value are given by the `limits endpoint. <https://developer.cognite.com/api#tag/Functions/operation/functionsLimits>`_, and None translates to the API default. On Azure, only the default value is used.
313-
runtime (RunTime | None): Runtime of the function. Allowed values are ["py39","py310", "py311", "py312"]. The runtime "py312" resolves to the latest version of the Python 3.12 series.
313+
runtime (RunTime | None): Runtime of the function. Allowed values are ["py310", "py311", "py312"]. The runtime "py312" resolves to the latest version of the Python 3.12 series.
314314
metadata (dict[str, str] | None): Metadata associated with a function as a set of key:value pairs.
315315
index_url (str | None): Specify a different python package index, allowing for packages published in private repositories. Supports basic HTTP authentication as described in pip basic authentication. See the documentation for additional information related to the security risks of using this option.
316316
extra_index_urls (list[str] | None): Extra package index URLs to use when building the function, allowing for packages published in private repositories. Supports basic HTTP authentication as described in pip basic authentication. See the documentation for additional information related to the security risks of using this option.
@@ -745,7 +745,7 @@ class FunctionsLimits(CogniteResponse):
745745
timeout_minutes (int): Timeout of each function call.
746746
cpu_cores (dict[str, float]): The number of CPU cores per function execution (i.e. function call).
747747
memory_gb (dict[str, float]): The amount of available memory in GB per function execution (i.e. function call).
748-
runtimes (list[str]): Available runtimes. For example, "py312" translates to the latest version of the Python 3.12 series.
748+
runtimes (list[RunTime]): Available runtimes. For example, "py312" translates to the latest version of the Python 3.12 series.
749749
response_size_mb (int | None): Maximum response size of function calls.
750750
"""
751751

@@ -754,13 +754,13 @@ def __init__(
754754
timeout_minutes: int,
755755
cpu_cores: dict[str, float],
756756
memory_gb: dict[str, float],
757-
runtimes: list[str],
757+
runtimes: list[RunTime],
758758
response_size_mb: int | None = None,
759759
) -> None:
760760
self.timeout_minutes = timeout_minutes
761761
self.cpu_cores = cpu_cores
762762
self.memory_gb = memory_gb
763-
self.runtimes = runtimes
763+
self.runtimes: list[RunTime] = runtimes
764764
self.response_size_mb = response_size_mb
765765

766766
@classmethod

tests/tests_unit/test_api/test_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def mock_functions_limit_response(rsps, cognite_client):
359359
"cpuCores": {"min": 0.1, "max": 0.6, "default": 0.25},
360360
"memoryGb": {"min": 0.1, "max": 2.5, "default": 1.0},
361361
"responseSizeMb": 1,
362-
"runtimes": ["py39", "py310", "py311"],
362+
"runtimes": ["py310", "py311", "py312"],
363363
}
364364
url = full_url(cognite_client, "/functions/limits")
365365
rsps.add(rsps.GET, url, status=200, json=response_body)

0 commit comments

Comments
 (0)