simulacrum-sdk 0.2.2__py3-none-any.whl → 0.2.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of simulacrum-sdk might be problematic. Click here for more details.

simulacrum/client.py CHANGED
@@ -41,7 +41,7 @@ class Simulacrum:
41
41
  }
42
42
 
43
43
  def forecast(
44
- self, series: Sequence[float] | np.ndarray, horizon: int, model: str = "default"
44
+ self, series: Sequence[float] | np.ndarray, horizon: int | None = None, model: str = "default"
45
45
  ) -> np.ndarray:
46
46
  """Request a forecast for the provided time series.
47
47
 
@@ -86,6 +86,8 @@ class Simulacrum:
86
86
  series=series_to_send, horizon=horizon, model=model
87
87
  )
88
88
  request_body: Dict[str, Any] = payload.model_dump()
89
+ # Exclude optional fields that are None (e.g., horizon for onsiteiq)
90
+ request_body = payload.model_dump(exclude_none=True)
89
91
  response_data: Dict[str, Any] = send_request(
90
92
  method="POST",
91
93
  url=f"{self.base_url}/{model}/v1/forecast",
simulacrum/models.py CHANGED
@@ -12,7 +12,7 @@ class ForecastRequest(BaseModel):
12
12
 
13
13
  Attributes:
14
14
  series (list[float]): Historical observations used as forecast input.
15
- horizon (int): Number of future periods to predict.
15
+ horizon (int | None): Number of future periods to predict. Optional for the ``"onsiteiq"`` model.
16
16
  model (str | None): Identifier of the forecasting model, defaults to ``"default"``.
17
17
 
18
18
  Example:
@@ -23,7 +23,7 @@ class ForecastRequest(BaseModel):
23
23
  """
24
24
 
25
25
  series: List[float]
26
- horizon: int
26
+ horizon: Optional[int] = None
27
27
  model: Optional[str] = "default"
28
28
 
29
29
  @field_validator("series", mode="before")
@@ -41,6 +41,23 @@ class ForecastRequest(BaseModel):
41
41
  return value.astype(float).tolist()
42
42
  return list(value)
43
43
 
44
+ @model_validator(mode="after")
45
+ def _validate_horizon_requirement(self):
46
+ # Horizon is required for all models except onsiteiq
47
+ model_name = (self.model or "").lower()
48
+ if model_name != "onsiteiq" and self.horizon is None:
49
+ raise ValueError("horizon is required and must be a positive integer for this model")
50
+
51
+ # When provided, horizon must be an integer >= 1
52
+ if self.horizon is not None:
53
+ if not isinstance(self.horizon, int):
54
+ raise ValueError(
55
+ f"horizon must be an integer (got {type(self.horizon).__name__})"
56
+ )
57
+ if self.horizon < 1:
58
+ raise ValueError("horizon must be >= 1")
59
+ return self
60
+
44
61
 
45
62
  class ForecastResponse(BaseModel):
46
63
  """Forecast output returned by the API.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simulacrum-sdk
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Official Python SDK for accessing the Simulacrum API.
5
5
  Author-email: "Simulacrum, Inc." <support@smlcrm.com>
6
6
  License-Expression: MIT
@@ -1,12 +1,12 @@
1
1
  simulacrum/__init__.py,sha256=RUetyuqgZ35UgPPcKHJAxqyh8aNkuB8AMWIevCc3iew,437
2
2
  simulacrum/_errors.py,sha256=lE6I8c4uL7HC6orHBJ5B1kz7x5NKDHd3mP2yjpQjeIg,2803
3
3
  simulacrum/api.py,sha256=dj1xF6KfBLHMML0AicnoHElRzaNjPxooQxBARX219c0,1645
4
- simulacrum/client.py,sha256=fCIGpHXgt89GO9UIcXNvVohJ-trRKqOwHL6B9K4rh3I,4874
4
+ simulacrum/client.py,sha256=uV3OlCCetni-O3-ESYtQcT8SR3MMj5MercatbH6YkrI,5026
5
5
  simulacrum/config.py,sha256=n3iN-cVUF3ucINS3iydDgMnFoMtVxDeVBIQwGiMKNk8,157
6
6
  simulacrum/exceptions.py,sha256=YrqoQjaPcZI31PmXd5evOl4fQjzxmz2sc8a3dSzkAMI,3408
7
- simulacrum/models.py,sha256=zmLTgfQNI6N1eruSCvmE8j0_N8mxP4oLpiIkj8yuZ08,2958
8
- simulacrum_sdk-0.2.2.dist-info/licenses/LICENSE,sha256=A7B9zAs2uCAzJoZPPyJW0G86yM-BTyum90vD4nSsOe0,1084
9
- simulacrum_sdk-0.2.2.dist-info/METADATA,sha256=vUbfXp3Qy1So7J166GJfgRbvF22Ok5XmvqvNqH8ljN4,6326
10
- simulacrum_sdk-0.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- simulacrum_sdk-0.2.2.dist-info/top_level.txt,sha256=CLUzfwEa7vZDf6zBAH8eXC2lZLMtj92MlXHOc3-V16o,11
12
- simulacrum_sdk-0.2.2.dist-info/RECORD,,
7
+ simulacrum/models.py,sha256=6ssKnWOIKLZZ98N5nrbcZh0S6yqr-qgJ6FKiV6nqELQ,3764
8
+ simulacrum_sdk-0.2.3.dist-info/licenses/LICENSE,sha256=A7B9zAs2uCAzJoZPPyJW0G86yM-BTyum90vD4nSsOe0,1084
9
+ simulacrum_sdk-0.2.3.dist-info/METADATA,sha256=QfKCHhIHeGNkEyzoc5BrldUj4RRlNC4vZdPBcGwC_6U,6326
10
+ simulacrum_sdk-0.2.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ simulacrum_sdk-0.2.3.dist-info/top_level.txt,sha256=CLUzfwEa7vZDf6zBAH8eXC2lZLMtj92MlXHOc3-V16o,11
12
+ simulacrum_sdk-0.2.3.dist-info/RECORD,,