diff --git a/docs/16.thanks.md b/docs/16.thanks.md index 983727070..79176de3e 100644 --- a/docs/16.thanks.md +++ b/docs/16.thanks.md @@ -24,6 +24,7 @@ We are grateful to all the people who helped us with the project. - [852Kerfunkle](https://github.com/852Kerfunkle) - [aguillon](https://github.com/aguillon) - [Anshit Bhardwaj](https://github.com/Anshit01) +- [Anton Rudenko](https://github.com/MrRoudyk) - [arrijabba](https://github.com/arrijabba) - [Do Quang Huy](https://github.com/huydo2105) - [Fitblip](https://github.com/Fitblip) @@ -42,6 +43,7 @@ We are grateful to all the people who helped us with the project. - [Scott Simpson](https://github.com/scottincrypto) - [shuoer86](https://github.com/shuoer86) - [Simon Bihel](https://github.com/sbihel) +- [Soham Das](https://github.com/tosoham) - [tomsib2001](https://github.com/tomsib2001) If we forgot to mention you, or you want to update your record, please, open an issue or pull request. diff --git a/docs/7.references/2.config.md b/docs/7.references/2.config.md index 4cab7c06e..120fe8c8a 100644 --- a/docs/7.references/2.config.md +++ b/docs/7.references/2.config.md @@ -333,7 +333,7 @@ description: "Config file reference" ## dipdup.config.HasuraConfig -class dipdup.config.HasuraConfig(url, admin_secret=None, create_source=False, source='default', select_limit=1000, allow_aggregations=True, allow_inconsistent_metadata=False, camel_case=False, rest=True, http=None) +class dipdup.config.HasuraConfig(url, admin_secret=None, create_source=False, source='default', select_limit=1000, allow_aggregations=True, allow_inconsistent_metadata=False, camel_case=False, rest=True, http=None, ignore_internal=False, ignore=None)

Config for the Hasura integration.

Parameters:
@@ -348,6 +348,8 @@ description: "Config file reference"
  • camel_case (bool) – Whether to use camelCase instead of default pascal_case for the field names.

  • rest (bool) – Enable REST API both for autogenerated and custom queries.

  • http (HttpConfig | None) – HTTP connection tunables

  • +
  • ignore_internal (bool) – Whether to ignore internal tables (prefixed with “dipdup”) when generating the GraphQL API.

  • +
  • ignore (list[str]) – List of additional table names to ignore when generating the GraphQL API.

  • diff --git a/docs/9.release-notes/_8.0_changelog.md b/docs/9.release-notes/_8.0_changelog.md index f20cb17da..76a0ceede 100644 --- a/docs/9.release-notes/_8.0_changelog.md +++ b/docs/9.release-notes/_8.0_changelog.md @@ -14,6 +14,7 @@ - env: Added `DIPDUP_JSON_LOG` environment variable to enable JSON logging. - env: Added `DIPDUP_LOW_MEMORY` variable to reduce the size of caches and buffers. - env: Added `DIPDUP_PACKAGE_PATH` environment variable to override discovered package path. +- hasura: Added `ignore` and `ignore_internal` config options to hide specific tables/views. - package: Added built-in `batch` handler to modify higher-level indexing logic. - starknet.events: Added `starknet.events` index kind to process Starknet events. - starknet.node: Added Starknet node datasource for last mile indexing. diff --git a/schemas/dipdup-3.0.json b/schemas/dipdup-3.0.json index f26031272..0f16d7f48 100644 --- a/schemas/dipdup-3.0.json +++ b/schemas/dipdup-3.0.json @@ -606,6 +606,14 @@ "additionalProperties": false, "description": "Config for the Hasura integration.", "properties": { + "ignore": { + "items": { + "type": "string" + }, + "title": "ignore", + "type": "array", + "description": "List of additional table names to ignore when generating the GraphQL API." + }, "url": { "$ref": "#/$defs/Url", "title": "url", @@ -678,6 +686,12 @@ "default": null, "title": "http", "description": "HTTP connection tunables" + }, + "ignore_internal": { + "default": false, + "title": "ignore_internal", + "type": "boolean", + "description": "Whether to ignore internal tables (prefixed with \"dipdup\") when generating the GraphQL API." } }, "required": [ diff --git a/src/dipdup/cli.py b/src/dipdup/cli.py index c4e74e4f6..95751363c 100644 --- a/src/dipdup/cli.py +++ b/src/dipdup/cli.py @@ -12,9 +12,9 @@ from pathlib import Path from typing import TYPE_CHECKING from typing import Any +from typing import TypedDict from typing import TypeVar from typing import cast -from typing import TypedDict import click import uvloop @@ -188,7 +188,7 @@ async def _check_version() -> None: _logger.info(_skip_msg) return - from appdirs import user_cache_dir + from appdirs import user_cache_dir # type: ignore[import-untyped] cache_file = Path(user_cache_dir('dipdup')) / 'version_info.json' @@ -196,7 +196,7 @@ async def _check_version() -> None: if latest_version: _warn_if_outdated(_skip_msg, latest_version) return - + import aiohttp async with AsyncExitStack() as stack: @@ -204,8 +204,8 @@ async def _check_version() -> None: session = await stack.enter_async_context(aiohttp.ClientSession()) response = await session.get('https://api.github.com/repos/dipdup-io/dipdup/releases/latest') response_json = await response.json() - latest_version = response_json['tag_name'] - + latest_version = cast(str, response_json['tag_name']) + _warn_if_outdated(_skip_msg, latest_version) _write_cached_version(cache_file, latest_version) @@ -213,6 +213,7 @@ async def _check_version() -> None: def _get_cached_version(cache_file: Path, ttl: int = 86400) -> str | None: # NOTE: Time-to-live (ttl) for the cache in seconds (default: 86400 seconds = 24 hours) import time + try: if (time.time() - cache_file.stat().st_mtime) >= ttl: return None @@ -239,11 +240,12 @@ def _read_cached_version(cache_file: Path) -> CachedVersion | None: def _write_cached_version(cache_file: Path, latest_version: str) -> None: try: - from dipdup.utils import json_dumps, write + from dipdup.utils import json_dumps + from dipdup.utils import write version_info: CachedVersion = { 'latest_version': latest_version, - 'installed_version': __version__ + 'installed_version': __version__, } write(cache_file, json_dumps(version_info), overwrite=True) except Exception as e: @@ -371,7 +373,6 @@ async def cli(ctx: click.Context, config: list[str], env_file: list[str], c: lis # Remember to import fire_and_forget: from dipdup.sys import fire_and_forget await _check_version() - try: # NOTE: Avoid early import errors if project package is incomplete. # NOTE: `ConfigurationError` will be raised later with more details. diff --git a/src/dipdup/config/__init__.py b/src/dipdup/config/__init__.py index 079b7508e..7f5aa8b98 100644 --- a/src/dipdup/config/__init__.py +++ b/src/dipdup/config/__init__.py @@ -375,7 +375,7 @@ class HasuraConfig: :param camel_case: Whether to use camelCase instead of default pascal_case for the field names. :param rest: Enable REST API both for autogenerated and custom queries. :param http: HTTP connection tunables - :param ignore_internal: Whether to ignore internal tables (prefixed with 'dipdup_') when generating the GraphQL API. + :param ignore_internal: Whether to ignore internal tables (prefixed with "dipdup") when generating the GraphQL API. :param ignore: List of additional table names to ignore when generating the GraphQL API. """ diff --git a/src/dipdup/hasura.py b/src/dipdup/hasura.py index 53890559f..252e6f67d 100644 --- a/src/dipdup/hasura.py +++ b/src/dipdup/hasura.py @@ -373,7 +373,7 @@ async def _generate_source_tables_metadata(self) -> list[dict[str, Any]]: metadata_tables[view] = self._format_table(view) for app, model in iter_models(self._package): - table_name = model_tables.get(f'{app}.{model.__name__}') + table_name = model_tables.get(f'{app}.{model.__name__}') # type: ignore[assignment] if not table_name: continue