Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DIPDUP_NO_VERSION_CHECK and DIPDUP_NO_SYMLINK variables #937

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic

## [Unreleased]

## Added

- env: Added `DIPDUP_NO_VERSION_CHECK` and `DIPDUP_NO_SYMLINK` variables.

### Fixed

- cli: Do not consider config as oneshot if `tezos.tzkt.head` index is present.
Expand Down
18 changes: 10 additions & 8 deletions docs/5.advanced/2.feature-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ DipDup uses multiple environment variables internally. They read once on process

Please note that they are not currently a part of the public API and can be changed without notice.

| env variable | module path | description |
| -------------------- | ------------------------ | -------------------------------------------------------- |
| `DIPDUP_CI` | `dipdup.env.CI` | Running in GitHub Actions |
| `DIPDUP_DEBUG` | `dipdup.env.DEBUG` | Enable debug logging and additional checks |
| `DIPDUP_DOCKER` | `dipdup.env.DOCKER` | Running in Docker |
| `DIPDUP_NEXT` | `dipdup.env.NEXT` | Enable experimental features that require schema changes |
| `DIPDUP_REPLAY_PATH` | `dipdup.env.REPLAY_PATH` | Path to datasource replay files; used in tests |
| `DIPDUP_TEST` | `dipdup.env.TEST` | Running in pytest |
| env variable | module path | description |
| ------------------------- | ----------------------------- | -------------------------------------------------------------------- |
| `DIPDUP_CI` | `dipdup.env.CI` | Running in GitHub Actions |
| `DIPDUP_DEBUG` | `dipdup.env.DEBUG` | Enable debug logging and additional checks |
| `DIPDUP_DOCKER` | `dipdup.env.DOCKER` | Running in Docker |
| `DIPDUP_NEXT` | `dipdup.env.NEXT` | Enable experimental features that require schema changes |
| `DIPDUP_NO_VERSION_CHECK` | `dipdup.env.NO_VERSION_CHECK` | Disable warning about running unstable or out-of-date DipDup version |
| `DIPDUP_NO_SYMLINK` | `dipdup.env.NO_SYMLINK` | Don't create magic symlink in th package root even when used as cwd |
| `DIPDUP_REPLAY_PATH` | `dipdup.env.REPLAY_PATH` | Path to datasource replay files; used in tests |
| `DIPDUP_TEST` | `dipdup.env.TEST` | Running in pytest |

`DIPDUP_NEXT` flag will give you the picture of what's coming in the next major release, but enabling it on the existing schema will trigger a reindexing.
2 changes: 1 addition & 1 deletion src/dipdup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ async def cli(ctx: click.Context, config: list[str], env_file: list[str]) -> Non
_config.initialize()

# NOTE: Fire and forget, do not block instant commands
if not any((_config.advanced.skip_version_check, env.TEST, env.CI)):
if not any((_config.advanced.skip_version_check, env.TEST, env.CI, env.NO_VERSION_CHECK)):
fire_and_forget(_check_version())

try:
Expand Down
8 changes: 7 additions & 1 deletion src/dipdup/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def set_test() -> None:
DEBUG: bool
DOCKER: bool
NEXT: bool
NO_SYMLINK: bool
NO_VERSION_CHECK: bool
REPLAY_PATH: Path | None
TEST: bool

Expand All @@ -83,17 +85,21 @@ def dump() -> dict[str, str]:
'DIPDUP_DEBUG': get('DIPDUP_DEBUG') or '',
'DIPDUP_DOCKER': get('DIPDUP_DOCKER') or '',
'DIPDUP_NEXT': get('DIPDUP_NEXT') or '',
'DIPDUP_NO_SYMLINK': get('DIPDUP_NO_SYMLINK') or '',
'DIPDUP_NO_VERSION_CHECK': get('DIPDUP_NO_VERSION_CHECK') or '',
'DIPDUP_REPLAY_PATH': get('DIPDUP_REPLAY_PATH') or '',
'DIPDUP_TEST': get('DIPDUP_TEST') or '',
}


def read() -> None:
global CI, DEBUG, DOCKER, NEXT, REPLAY_PATH, TEST
global CI, DEBUG, DOCKER, NEXT, NO_SYMLINK, NO_VERSION_CHECK, REPLAY_PATH, TEST
CI = get_bool('DIPDUP_CI')
DEBUG = get_bool('DIPDUP_DEBUG')
DOCKER = get_bool('DIPDUP_DOCKER')
NEXT = get_bool('DIPDUP_NEXT')
NO_SYMLINK = get_bool('DIPDUP_NO_SYMLINK')
NO_VERSION_CHECK = get_bool('DIPDUP_NO_VERSION_CHECK')
REPLAY_PATH = get_path('DIPDUP_REPLAY_PATH')
TEST = get_bool('DIPDUP_TEST')

Expand Down
3 changes: 2 additions & 1 deletion src/dipdup/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pydantic import BaseModel
from pydantic.dataclasses import dataclass

from dipdup import env
from dipdup.exceptions import ProjectImportError
from dipdup.project import Answers
from dipdup.project import answers_from_replay
Expand Down Expand Up @@ -140,7 +141,7 @@ def _pre_init(self) -> None:

def _post_init(self) -> None:
# NOTE: Allows plain package structure to be imported
if self.root != Path.cwd():
if self.root != Path.cwd() or env.NO_SYMLINK:
return

symlink_path = self.root.joinpath(self.name)
Expand Down
Loading