:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(warehouse_sources): support OpenWeather API version 4.0 (#95586)
Tom Owersb3480bb4ef6b
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.mdindex 6802b8d05b46..ff9ae85348d5 100644--- a/.agents/skills/warehouse-source-new-version/SKILL.md+++ b/.agents/skills/warehouse-source-new-version/SKILL.md@@ -45,7 +45,7 @@ Add it when any of these hold:## Adding a new version, step by step-1. **Read the vendor's changelog** (the source's `api_docs_url`) and list what changed between the currently supported version(s) and the new one: renamed/removed fields, changed pagination, new required headers, changed webhook payloads, or a field the source reads becoming opt-in behind a new query parameter (a field returned by default in the old version now empty unless requested — restore it by adding that parameter on the new version's request path). Verification is docs-only — there are no stored credentials and no live-sync harness, so the docs are the sole source of truth for what each version serves. This is also the evidence the gate above runs on.+1. **Read the vendor's changelog** (the source's `api_docs_url`) and list what changed between the currently supported version(s) and the new one: renamed/removed fields, changed pagination, new required headers, changed webhook payloads, or a field the source reads becoming opt-in behind a new query parameter (a field returned by default in the old version now empty unless requested — restore it by adding that parameter on the new version's request path). Verification is docs-only — there are no stored credentials and no live-sync harness, so the docs are the sole source of truth for what each version serves. When the vendor's docs page renders client-side and comes back as an empty shell, read its machine-readable mirror (an `llms.txt`, a `sitemap.md`, or the same path with a `.md` suffix) rather than treating the version as undocumented. This is also the evidence the gate above runs on.2. **Declare the version** (only once the gate says the version has to exist): add the new label to `supported_versions` and flip `default_version` to it — new sources always start on the newest stable version. A pinned row's **sync** path is unaffected by a default flip (that is the point of pinning), but two things still follow the new default: discovery/`get_schemas` if the pin isn't threaded there (step 3), and any row whose `api_version` is NULL. Reference the request layer's version constants instead of duplicating string literals.3. **Dispatch on `SourceInputs.api_version`** at the request layer:- Keep it minimal. If the version is just a header/URL segment and response shapes are compatible, thread the version string down to where the client/URL is built (see Stripe: `StripeSource.source_for_pipeline` passes `self.resolve_api_version(inputs.api_version)` → `stripe_source(...)` → `StripeClient(stripe_version=...)`). Resolve through `resolve_api_version` at the source class — never hardcode a fallback version in the request layer.@@ -90,6 +90,7 @@ Add it when any of these hold:- Discovery diffs under the SOURCE pin (`sync_new_schemas`, `refresh_schemas`, bulk sync-defaults). A schema-level `api_version` override on a version whose table set differs from the source's version can be disabled/soft-deleted by that diff — keep overrides to short verification windows, not as a long-term way to hold one table on another version.- When a versioned source sends the pin on any vendor call — discovery _or_ sync (a static endpoint catalog doesn't consume it at discovery, but `get_rows` still sends the version header) — add the vendor's version-rejection error signature (e.g. `406`/`410`) to `get_non_retryable_errors`, otherwise a retired pin turns the retry cadence into a permanent error loop with no user-facing surface.- A version bump can change the auth scheme, not just the wire format. Then the source config needs both credential shapes as optional fields, auth construction dispatches on the resolved version, and `validate_credentials` enforces the pair that version needs — form-level `required` can't express "depends on the pin".+- A new version can page a horizon the old one returned whole (a fixed record cap plus `next`/`prev` links). For a snapshot-polling source, keep one request per sync rather than following the links — vendors bill each page — and state the resulting horizon in each table's description, since it can be shorter than the old version's.- A version that changes the pagination _mechanism_ (e.g. offset→cursor) also changes the resumable checkpoint's persisted shape. Add a new defaulted field to the resume-config dataclass rather than repurposing the existing one — so state persisted under the old version still decodes — and make the seed and save-checkpoint logic dispatch on the resolved version. Reusing one field across incompatible mechanisms corrupts in-flight resumes of the other version.- When the vendor renames a collection between versions, keep the schema/table name set identical across versions and put the rename in a per-version path on the endpoint config — otherwise discovery diffs orphan the table on repin.- When the new version has no equivalent for an old endpoint (a dropped collection, not a rename), keep that table only on the versions that serve it and let the table set differ by version — never map it to a guessed path just to keep the sets equal, since docs are the sole source of truth and an unverified path makes a new source surface a table that 404s at sync time.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/canonical_descriptions.pyindex eaf79510d0bf..80176e23d377 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/canonical_descriptions.py@@ -11,6 +11,9 @@ _INJECTED_COLUMNS = {"dt": "Time of the data, Unix UTC timestamp.",}+# One Call 4.0 returns alert IDs inline on weather rows; the full alert is a separate lookup.+_ALERTS_COLUMN = "IDs of the government weather alerts covering the location, from the One Call API 4.0."+CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"current_weather": {"description": "Current weather snapshot for a configured location, from the OpenWeather Current Weather Data API.",@@ -71,10 +74,11 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"components": "Forecasted pollutant concentrations in μg/m³: co, no, no2, o3, so2, pm2_5, pm10, nh3.",},},- # One Call API 3.0 tables. Each row is one section of the shared `/data/3.0/onecall` response.+ # One Call tables, served by both One Call 3.0 (one section of the shared `/data/3.0/onecall`+ # response) and One Call 4.0 (one endpoint per table)."current": {- "description": "Current weather snapshot for a configured location, from the OpenWeather One Call API 3.0.",- "docs_url": "https://openweathermap.org/api/one-call-3",+ "description": "Current weather snapshot for a configured location, from the OpenWeather One Call API.",+ "docs_url": "https://openweathermap.org/api/one-call-4","columns": {**_INJECTED_COLUMNS,"temp": "Temperature (units depend on the `units` request parameter; standard is Kelvin).",@@ -93,11 +97,44 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"sunrise": "Sunrise time, Unix UTC timestamp.","sunset": "Sunset time, Unix UTC timestamp.","weather": "List of weather condition objects (id, main, description, icon).",+ "alerts": _ALERTS_COLUMN,+ },+ },+ "minutely": {+ "description": "Minute-by-minute precipitation forecast for the next hour; one row per minute.",+ "docs_url": "https://openweathermap.org/api/one-call-4",+ "columns": {+ **_INJECTED_COLUMNS,+ "precipitation": "Forecasted precipitation volume for the minute, mm/h.",+ "alerts": _ALERTS_COLUMN,+ },+ },+ "quarter_hourly": {+ "description": "15 minute weather forecast timeline for a configured location; one row per 15 minute slot.",+ "docs_url": "https://openweathermap.org/api/one-call-4",+ "columns": {+ **_INJECTED_COLUMNS,+ "temp": "Forecasted temperature for the slot.",+ "feels_like": "Human-perceived temperature for the slot.",+ "pressure": "Atmospheric pressure at sea level, hPa.",+ "humidity": "Humidity, as a percentage.",+ "dew_point": "Atmospheric temperature below which dew forms.",+ "uvi": "UV index.",+ "clouds": "Cloudiness, as a percentage.",+ "visibility": "Average visibility in metres.",+ "wind_speed": "Wind speed.",+ "wind_gust": "Wind gust, where available.",+ "wind_deg": "Wind direction, degrees (meteorological).",+ "pop": "Probability of precipitation, from 0 to 1.",+ "rain": "Rain volume for the slot, where available (`1h`).",+ "snow": "Snow volume for the slot, where available (`1h`).",+ "weather": "List of weather condition objects for the slot.",+ "alerts": _ALERTS_COLUMN,},},"hourly": {- "description": "Hourly weather forecast (48 hours) for a configured location; one row per hour.",- "docs_url": "https://openweathermap.org/api/one-call-3",+ "description": "Hourly weather forecast for a configured location; one row per hour.",+ "docs_url": "https://openweathermap.org/api/one-call-4","columns": {**_INJECTED_COLUMNS,"temp": "Forecasted temperature for the hour.",@@ -115,11 +152,12 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"rain": "Rain volume for the hour, where available (`1h`).","snow": "Snow volume for the hour, where available (`1h`).","weather": "List of weather condition objects for the hour.",+ "alerts": _ALERTS_COLUMN,},},"daily": {- "description": "Daily weather forecast (8 days) for a configured location; one row per day.",- "docs_url": "https://openweathermap.org/api/one-call-3",+ "description": "Daily weather forecast for a configured location; one row per day.",+ "docs_url": "https://openweathermap.org/api/one-call-4","columns": {**_INJECTED_COLUMNS,"summary": "Human-readable summary of the day's weather.",@@ -142,6 +180,8 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"moonset": "Moonset time, Unix UTC timestamp.","moon_phase": "Moon phase, from 0 to 1.","weather": "List of weather condition objects for the day.",+ "visibility": "Average visibility in metres.",+ "alerts": _ALERTS_COLUMN,},},}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/settings.pyindex b437fee2220c..c89eec461d6c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/settings.py@@ -36,10 +36,11 @@ class OpenWeatherEndpointConfig:# Opaque vendor version labels (never parsed or ordered). The Current Weather, 5 Day / 3 Hour-# Forecast and Air Pollution APIs are served under `2.5`; the One Call product's current stable-# release is `3.0` (One Call 2.5 was closed in June 2024).+# Forecast and Air Pollution APIs are served under `2.5`; the One Call product runs on `3.0` and,+# since June 2026, `4.0` (One Call 2.5 was closed in June 2024).API_VERSION_2_5 = "2.5"API_VERSION_3_0 = "3.0"+API_VERSION_4_0 = "4.0"# The 2.5 general-purpose APIs. Each endpoint is its own request per location per sync.OPENWEATHER_ENDPOINTS: dict[str, OpenWeatherEndpointConfig] = {@@ -96,16 +97,63 @@ OPENWEATHER_ENDPOINTS_3_0: dict[str, OpenWeatherEndpointConfig] = {),}+# The One Call API 4.0 splits the 3.0 response into one endpoint per timeline step, so each table+# is its own request. Every endpoint answers with the same `{lat, lon, timezone, data: [...]}`+# envelope, and each `data` item carries its own `dt`, so the shared `[lat, lon, dt]` key and+# `dt_iso` partition still apply. `current`, `hourly` and `daily` keep the 3.0 table names so a+# 4.0 source exposes the same tables under different paths.+_ONECALL_4_BASE = "/data/4.0/onecall"+# Timeline endpoints answer a fixed-size page and offer `next`/`prev` URLs to walk further. We read+# the first page only: each page is billed as its own call, and one request per location per sync is+# the cost the source's setup copy promises.+OPENWEATHER_ENDPOINTS_4_0: dict[str, OpenWeatherEndpointConfig] = {+ "current": OpenWeatherEndpointConfig(+ name="current",+ path=f"{_ONECALL_4_BASE}/current",+ data_key="data",+ description="Current weather snapshot for each configured location, from the One Call API 4.0. "+ "One row per location per sync; use append sync to accumulate a time series.",+ ),+ "minutely": OpenWeatherEndpointConfig(+ name="minutely",+ path=f"{_ONECALL_4_BASE}/timeline/1min",+ data_key="data",+ description="Minute-by-minute precipitation forecast for the next hour. One row per minute per location.",+ ),+ "quarter_hourly": OpenWeatherEndpointConfig(+ name="quarter_hourly",+ path=f"{_ONECALL_4_BASE}/timeline/15min",+ data_key="data",+ description="15 minute weather forecast timeline. One row per 15 minute slot, up to 50 slots ahead "+ "of the sync time.",+ ),+ "hourly": OpenWeatherEndpointConfig(+ name="hourly",+ path=f"{_ONECALL_4_BASE}/timeline/1h",+ data_key="data",+ description="Hourly weather forecast timeline. One row per hour, up to 20 hours ahead of the sync time.",+ ),+ "daily": OpenWeatherEndpointConfig(+ name="daily",+ path=f"{_ONECALL_4_BASE}/timeline/1day",+ data_key="data",+ description="Daily weather forecast timeline. One row per day, up to 10 days ahead of the sync time.",+ ),+}+OPENWEATHER_ENDPOINTS_BY_VERSION: dict[str, dict[str, OpenWeatherEndpointConfig]] = {API_VERSION_2_5: OPENWEATHER_ENDPOINTS,API_VERSION_3_0: OPENWEATHER_ENDPOINTS_3_0,+ API_VERSION_4_0: OPENWEATHER_ENDPOINTS_4_0,}# The endpoint each version's credential probe hits — chosen so it exercises the same product-# (and subscription) the sync reads, not just any key-accepting endpoint.+# (and subscription) the sync reads, not just any key-accepting endpoint. A 4.0 subscription is+# sold separately from a 3.0 one, so probing 4.0's own endpoint is what catches an unsubscribed key.PROBE_ENDPOINT_BY_VERSION: dict[str, str] = {API_VERSION_2_5: "current_weather",API_VERSION_3_0: "current",+ API_VERSION_4_0: "current",}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/source.pyindex f475bee8dea4..fbf46471b83e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/source.py@@ -26,6 +26,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.openweathefrom products.warehouse_sources.backend.temporal.data_imports.sources.openweather.settings import (API_VERSION_2_5,API_VERSION_3_0,+ API_VERSION_4_0,endpoints_for_version,)from products.warehouse_sources.backend.types import ExternalDataSourceType@@ -33,8 +34,8 @@ from products.warehouse_sources.backend.types import ExternalDataSourceType@SourceRegistry.registerclass OpenWeatherSource(SimpleSource[OpenWeatherSourceConfig]):- supported_versions = (API_VERSION_2_5, API_VERSION_3_0)- default_version = API_VERSION_3_0+ supported_versions = (API_VERSION_2_5, API_VERSION_3_0, API_VERSION_4_0)+ default_version = API_VERSION_4_0api_docs_url = "https://openweathermap.org/api"@propertydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/tests/test_openweather.py b/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/tests/test_openweather.pyindex 171cb82e5e57..b5387e45dc30 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/tests/test_openweather.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/tests/test_openweather.py@@ -25,6 +25,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.openweathefrom products.warehouse_sources.backend.temporal.data_imports.sources.openweather.settings import (API_VERSION_2_5,API_VERSION_3_0,+ API_VERSION_4_0,OPENWEATHER_ENDPOINTS,endpoints_for_version,)@@ -32,7 +33,9 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.openweathe# (version, endpoint) pairs across every supported version, so the request-path dispatch is# exercised for each._ALL_VERSIONED_ENDPOINTS = [- (version, endpoint) for version in (API_VERSION_2_5, API_VERSION_3_0) for endpoint in endpoints_for_version(version)+ (version, endpoint)+ for version in (API_VERSION_2_5, API_VERSION_3_0, API_VERSION_4_0)+ for endpoint in endpoints_for_version(version)]MODULE = "products.warehouse_sources.backend.temporal.data_imports.sources.openweather.openweather"@@ -183,6 +186,22 @@ class TestNormalizeRows:assert [row["dt"] for row in rows] == [1719158400, 1719244800]assert all(row["lat"] == 51.5 and row["lon"] == -0.12 for row in rows)+ def test_onecall_4_data_envelope_rows(self):+ # One Call 4.0 wraps every timeline in a shared `data` array alongside envelope metadata.+ endpoints = endpoints_for_version(API_VERSION_4_0)+ response = {+ "lat": 51.51,+ "lon": -0.13,+ "timezone": "Europe/London",+ "data": [{"dt": 1719158400, "temp": 280}, {"dt": 1719159300, "temp": 281}],+ "next": "https://api.openweathermap.org/data/4.0/onecall/timeline/15min?start=1719159300",+ }+ rows = _normalize_rows(endpoints["quarter_hourly"], response, Location(51.5, -0.12, "London"))++ assert [row["dt"] for row in rows] == [1719158400, 1719159300]+ assert all(row["lat"] == 51.5 and row["lon"] == -0.12 for row in rows)+ assert rows[0]["dt_iso"] == "2024-06-23T16:00:00+00:00"+def test_row_without_dt_raises(self):# `dt` is part of the primary key; a row missing it must fail loudly, not yield a null key.response = {"main": {"temp": 280}}@@ -280,6 +299,7 @@ class TestValidateCredentials:[(API_VERSION_2_5, "/data/2.5/weather"),(API_VERSION_3_0, "/data/3.0/onecall"),+ (API_VERSION_4_0, "/data/4.0/onecall/current"),],)def test_probes_version_endpoint_with_first_location(self, api_version, expected_path):@@ -324,18 +344,36 @@ class TestGetRows:assert batches == []- def test_onecall_requests_the_3_0_path(self):- # A 3.0-pinned source must hit `/data/3.0/onecall`, not the 2.5 paths.+ @pytest.mark.parametrize(+ "api_version, endpoint, body, expected_path",+ [+ (API_VERSION_2_5, "current_weather", {"dt": 1, "main": {"temp": 280}}, "/data/2.5/weather"),+ (API_VERSION_3_0, "current", {"current": {"dt": 1, "temp": 280}}, "/data/3.0/onecall"),+ (API_VERSION_4_0, "current", {"data": [{"dt": 1, "temp": 280}]}, "/data/4.0/onecall/current"),+ (API_VERSION_4_0, "minutely", {"data": [{"dt": 1, "precipitation": 0}]}, "/data/4.0/onecall/timeline/1min"),+ (+ API_VERSION_4_0,+ "quarter_hourly",+ {"data": [{"dt": 1, "temp": 280}]},+ "/data/4.0/onecall/timeline/15min",+ ),+ (API_VERSION_4_0, "hourly", {"data": [{"dt": 1, "temp": 280}]}, "/data/4.0/onecall/timeline/1h"),+ (API_VERSION_4_0, "daily", {"data": [{"dt": 1, "temp": {"day": 280}}]}, "/data/4.0/onecall/timeline/1day"),+ ],+ )+ def test_requests_the_pinned_versions_path(self, api_version, endpoint, body, expected_path):+ # Each pin must hit its own product's paths — a wrong path 404s or bills the wrong subscription.with mock.patch(f"{MODULE}.make_tracked_session") as mock_session:- mock_session.return_value.get.return_value = _response(200, {"current": {"dt": 1, "temp": 280}})+ mock_session.return_value.get.return_value = _response(200, body)- list(- get_rows("test-key", "current", [Location(51.5, -0.12, None)], structlog.get_logger(), API_VERSION_3_0)+ batches = list(+ get_rows("test-key", endpoint, [Location(51.5, -0.12, None)], structlog.get_logger(), api_version))called_url = mock_session.return_value.get.call_args[0][0]- assert called_url.startswith(f"{OPENWEATHER_BASE_URL}/data/3.0/onecall?")+ assert called_url.startswith(f"{OPENWEATHER_BASE_URL}{expected_path}?")+ assert batches[0][0]["dt"] == 1class TestOpenWeatherSource:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/tests/test_openweather_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/tests/test_openweather_source.pyindex 1fc6333c037b..99034424416e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/tests/test_openweather_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/openweather/tests/test_openweather_source.py@@ -10,13 +10,17 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.generated_from products.warehouse_sources.backend.temporal.data_imports.sources.openweather.settings import (API_VERSION_2_5,API_VERSION_3_0,+ API_VERSION_4_0,endpoints_for_version,)from products.warehouse_sources.backend.temporal.data_imports.sources.openweather.source import OpenWeatherSource_ALL_VERSIONED_ENDPOINTS = [- (version, endpoint) for version in (API_VERSION_2_5, API_VERSION_3_0) for endpoint in endpoints_for_version(version)+ (version, endpoint)+ for version in (API_VERSION_2_5, API_VERSION_3_0, API_VERSION_4_0)+ for endpoint in endpoints_for_version(version)]+_ONECALL_4_TABLES = {"current", "minutely", "quarter_hourly", "hourly", "daily"}def _make_inputs(schema_name: str = "current_weather", api_version: str | None = None) -> SourceInputs:@@ -43,15 +47,16 @@ class TestOpenWeatherSource:self.team_id = 123self.config = OpenWeatherSourceConfig(api_key="test-key", locations="51.5,-0.12,London")- def test_default_version_is_3_0(self):- # New sources are stamped with `default_version`; the 3.0 One Call product is now the default.- assert self.source.default_version == API_VERSION_3_0- assert set(self.source.supported_versions) == {API_VERSION_2_5, API_VERSION_3_0}+ def test_default_version_is_4_0(self):+ # New sources are stamped with `default_version`; the 4.0 One Call product is now the default.+ assert self.source.default_version == API_VERSION_4_0+ assert set(self.source.supported_versions) == {API_VERSION_2_5, API_VERSION_3_0, API_VERSION_4_0}@pytest.mark.parametrize("api_version, expected",[- (None, {"current", "hourly", "daily"}), # None → default_version (3.0)+ (None, _ONECALL_4_TABLES), # None → default_version (4.0)+ (API_VERSION_4_0, _ONECALL_4_TABLES),(API_VERSION_3_0, {"current", "hourly", "daily"}),(API_VERSION_2_5, {"current_weather", "forecast", "air_pollution", "air_pollution_forecast"}),],@@ -97,14 +102,15 @@ class TestOpenWeatherSource:assert is_valid is expected_validassert error_message == expected_message# No pin at validation time (pre-creation) resolves to the default version.- mock_validate.assert_called_once_with(self.config.api_key, self.config.locations, API_VERSION_3_0)+ mock_validate.assert_called_once_with(self.config.api_key, self.config.locations, API_VERSION_4_0)@pytest.mark.parametrize("pin, schema_name, expected_version",[- (None, "current", API_VERSION_3_0), # unpinned → default- (API_VERSION_3_0, "current", API_VERSION_3_0),- (API_VERSION_2_5, "forecast", API_VERSION_2_5), # a 2.5-pinned source keeps its version+ (None, "current", API_VERSION_4_0), # unpinned → default+ (API_VERSION_4_0, "quarter_hourly", API_VERSION_4_0),+ (API_VERSION_3_0, "current", API_VERSION_3_0), # a 3.0-pinned source keeps its version+ (API_VERSION_2_5, "forecast", API_VERSION_2_5),],)@mock.patch(