Skip to content

Commit

Permalink
Lint, update contributors (#1116)
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout authored Oct 1, 2024
1 parent b8c9c75 commit d856c61
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docs/16.thanks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
4 changes: 3 additions & 1 deletion docs/7.references/2.config.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ description: "Config file reference"

## dipdup.config.HasuraConfig

<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">dipdup.config.</span></span><span class="sig-name descname"><span class="pre">HasuraConfig</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">admin_secret</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">create_source</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">source</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'default'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">select_limit</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allow_aggregations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allow_inconsistent_metadata</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">camel_case</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rest</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">http</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span></dt>
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">dipdup.config.</span></span><span class="sig-name descname"><span class="pre">HasuraConfig</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">admin_secret</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">create_source</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">source</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'default'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">select_limit</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allow_aggregations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allow_inconsistent_metadata</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">camel_case</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rest</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">http</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ignore_internal</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ignore</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span></dt>
<dd><p>Config for the Hasura integration.</p>
<dl class="field-list simple">
<dt class="field-odd" style="color: var(--txt-primary);">Parameters<span class="colon">:</span></dt>
Expand All @@ -348,6 +348,8 @@ description: "Config file reference"
<li><p><strong>camel_case</strong> (<em>bool</em>) – Whether to use camelCase instead of default pascal_case for the field names.</p></li>
<li><p><strong>rest</strong> (<em>bool</em>) – Enable REST API both for autogenerated and custom queries.</p></li>
<li><p><strong>http</strong> (<a class="reference internal" href="#dipdupconfighttpconfig" title="dipdup.config.HttpConfig" target="_self"><em>HttpConfig</em></a><em> | </em><em>None</em>) – HTTP connection tunables</p></li>
<li><p><strong>ignore_internal</strong> (<em>bool</em>) – Whether to ignore internal tables (prefixed with “dipdup”) when generating the GraphQL API.</p></li>
<li><p><strong>ignore</strong> (<em>list</em><em>[</em><em>str</em><em>]</em>) – List of additional table names to ignore when generating the GraphQL API.</p></li>

</ul>
</dd>
Expand Down
1 change: 1 addition & 0 deletions docs/9.release-notes/_8.0_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions schemas/dipdup-3.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": [
Expand Down
17 changes: 9 additions & 8 deletions src/dipdup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -188,31 +188,32 @@ 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'

latest_version = _get_cached_version(cache_file)
if latest_version:
_warn_if_outdated(_skip_msg, latest_version)
return

import aiohttp

async with AsyncExitStack() as stack:
stack.enter_context(suppress(Exception))
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)


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
Expand All @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/dipdup/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand Down
2 changes: 1 addition & 1 deletion src/dipdup/hasura.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d856c61

Please sign in to comment.