Skip to content
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
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ Releases prior to 7.0 has been removed from this file to declutter search result

## [Unreleased]

### Fidex
### Added

- cli: Added `init --no-base` option to skip creating the base template.
- env: Added `DIPDUP_NO_BASE` environment variable to skip creating the base template.

### Fixed

- cli: Fixed `new` command using incorrect template.

### Changed

- cli: `init --base` option is now enabled by default.

## [8.3.1] - 2025-04-08

### Added
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ demos: ## Recreate demo projects from templates
DIPDUP_NO_SYMLINK=1 python scripts/demos.py init ${DEMO}

demos_refresh:
for demo in `ls src | grep demo | grep -v etherlink`; do cd src/$$demo && DIPDUP_NO_SYMLINK=1 dipdup init -b -f && cd ../..; done
for demo in `ls src | grep demo | grep -v etherlink`; do cd src/$$demo && DIPDUP_NO_SYMLINK=1 dipdup init --force && cd ../..; done

before_release: ## Prepare for a new release after updating version in pyproject.toml
make format lint update demos test docs
Expand Down
2 changes: 1 addition & 1 deletion docs/1.getting-started/1.installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ make install
source .venv/bin/activate
```

If you prefer to use other package manager, edit `configs/replay.yaml` file and run `dipdup init -b -f`.
If you prefer to use other package manager, edit `configs/replay.yaml` file and run `dipdup init --force`.

## Docker

Expand Down
2 changes: 1 addition & 1 deletion docs/1.getting-started/4.package.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ When upgrading to a newer version of DipDup, particularly major releases, you ma
To refresh your project package, run:

```shell [Terminal]
dipdup init -b -f
dipdup init --force
make install
```

Expand Down
2 changes: 1 addition & 1 deletion docs/12.faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ For historical reasons, Python package management is a mess. There are multiple

Using PDM/Poetry is not required to run DipDup, but strongly recommended. Choosing one over the other is a matter of personal preference. _As of writing_, Poetry is [faster](https://lincolnloop.github.io/python-package-manager-shootout/), more popular, and has a nicer CLI, while PDM is more PEP-compatible and allows dependency overrides.

You can choose the preferred tool (or none) when initializing a project with `dipdup new` command. If you change your mind later, modify the `replay.yaml` file and run `dipdup init --base --force`.
You can choose the preferred tool (or none) when initializing a project with `dipdup new` command. If you change your mind later, modify the `replay.yaml` file and run `dipdup init --force`.

## Miscellaneous

Expand Down
2 changes: 2 additions & 0 deletions docs/5.advanced/2.environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ DipDup uses multiple environment variables internally. They read once on process
| `DIPDUP_MIGRATIONS` | Enable migrations with `aerich` |
| `DIPDUP_NEXT` | Enable experimental features from the next major release that require schema changes |
| `DIPDUP_NO_SYMLINK` | Don't create magic symlink in the package root even when used as cwd |
| `DIPDUP_NO_LINTER` | Don't format and lint generated files with ruff |
| `DIPDUP_NO_BASE` | Don't generate project template base |
| `DIPDUP_NO_VERSION_CHECK` | Disable warning about running unstable or out-of-date DipDup version |
| `DIPDUP_PACKAGE_PATH` | Disable package discovery and use the specified path |
| `DIPDUP_REPLAY_PATH` | Path to datasource replay files; used in tests (dev only) |
Expand Down
8 changes: 7 additions & 1 deletion docs/7.references/1.cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ Discord: <a class="reference external" href="https://discord.gg/aG
<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-dipdup-init-b">
<span id="cmdoption-dipdup-init-base"></span><span class="sig-name descname"><span class="pre">-b</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--base</span></span><span class="sig-prename descclassname"></span></dt>
<dd><p>Include template base: pyproject.toml, Dockerfile, etc.</p>
<dd><p>Include template base (default)</p>
</dd></dl>

<dl class="std option">
<dt class="sig sig-object std" id="cmdoption-dipdup-init-0">
<span id="cmdoption-dipdup-init-no-base"></span><span class="sig-name descname"><span class="pre">-b</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--no-base</span></span><span class="sig-prename descclassname"></span></dt>
<dd><p>Skip template base</p>
</dd></dl>

<dl class="std option">
Expand Down
4 changes: 2 additions & 2 deletions docs/9.release-notes/1.v8.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ In this release, we've enhanced the integration:
- Default project templates are configured to use `uv` by default
- Better handling of dependencies and virtual environments

To switch to uv in existing projects, update your `configs/replay.yaml` and run `dipdup init -b -f`.
To switch to uv in existing projects, update your `configs/replay.yaml` and run `dipdup init --force`.

::banner{type="warning"}
Note that `uv` build backend (see [#3957](https://github.com/astral-sh/uv/issues/3957), available separately as `uv_build` package) doesn't support non-standard layout of DipDup packages. Hatchling build backend handles both editable and non-editable builds correctly.
Expand All @@ -56,7 +56,7 @@ Existing projects will continue to work with 8.3 without any modifications.
If you want to use recent improvements like the MCP server, uv package manager, and Ruff formatter, refresh your project template:

```shell [Terminal]
dipdup init -b -f
dipdup init --force
make install
```

Expand Down
4 changes: 4 additions & 0 deletions docs/9.release-notes/_8.0_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
- cli: Added `--pre` flag to `self` group commands to install pre-release versions.
- cli: Added `--raw` option to `config export` command to dump config preserving the original structure.
- cli: Added `-C` option, a shorthand for `-c . -c configs/dipdup.<name>.yaml`.
- cli: Added `init --no-base` option to skip creating the base template.
- cli: Added `package verify` command to check the package consistency.
- cli: Added full project migration support for 3.0 spec.
- cli: Added spec_version 3.0 support to `migrate` command.
- config: Publish JSON schemas for config validation and autocompletion.
- database: Added `dipdup_status` view to the schema.
- 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_NO_BASE` environment variable to skip creating the base template.
- env: Added `DIPDUP_PACKAGE_PATH` environment variable to override discovered package path.
- package: Added built-in `batch` handler to modify higher-level indexing logic.
- starknet.events: Added `starknet.events` index kind to process Starknet events.
Expand All @@ -25,6 +27,7 @@
- cli: Don't save reports for successful test runs.
- cli: Don't update existing installation in `self install` command unless asked to.
- cli: Fixed `--pre` installer flag.
- cli: Fixed `new` command using incorrect template.
- cli: Fixed env files not being loaded in some commands.
- cli: Fixed errors raised when the project package is invalid.
- cli: Fixed progress estimation when there are indexes with `last_level` option set.
Expand Down Expand Up @@ -54,6 +57,7 @@
### Changed

- api: `/performance` endpoint response format has been changed.
- cli: `init --base` option is now enabled by default.
- config: Index configs accept `datasources` list instead of `datasource` field.
- config: Index kinds have been renamed and grouped by the network.
- config: Index template values now can be any JSON-serializable object.
Expand Down
18 changes: 15 additions & 3 deletions src/dipdup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ def wrapper(ctx: click.Context, *args: Any, **kwargs: Any) -> None:
except (KeyboardInterrupt, asyncio.CancelledError):
pass
except Exception as e:
if isinstance(e, click.UsageError):
raise

from dipdup.report import save_report

package = ctx.obj.config.package if ctx.obj else 'unknown'
Expand Down Expand Up @@ -347,7 +350,8 @@ async def run(ctx: click.Context) -> None:

@cli.command()
@click.option('--force', '-f', is_flag=True, help='Overwrite existing types and ABIs.')
@click.option('--base', '-b', is_flag=True, help='Include template base: pyproject.toml, Dockerfile, etc.')
@click.option('--base', '-b', is_flag=True, help='Include template base (default)')
@click.option('--no-base', '-b', is_flag=True, help='Skip template base')
@click.option('--no-linter', is_flag=True, help='Skip linter and formatter.')
@click.argument(
'include',
Expand All @@ -361,6 +365,7 @@ async def init(
ctx: click.Context,
force: bool,
base: bool,
no_base: bool,
no_linter: bool,
include: list[str],
) -> None:
Expand All @@ -370,12 +375,17 @@ async def init(
"""
from dipdup.dipdup import DipDup

if base:
if no_base:
raise click.BadParameter('You cannot use both `--base` and `--no-base` options at the same time')
_logger.warning('`--base` option became default; use `--no-base` to disable it')

config: DipDupConfig = ctx.obj.config
dipdup = DipDup(config)

await dipdup.init(
force=force,
base=base or bool(include),
no_base=no_base or bool(include),
no_linter=no_linter,
include=set(include),
)
Expand Down Expand Up @@ -416,9 +426,10 @@ async def migrate(ctx: click.Context, dry_run: bool) -> None:
)
await _cli_unwrapper(init)(
ctx=ctx,
base=True,
base=False,
force=True,
no_linter=True,
no_base=False,
include=[],
)

Expand Down Expand Up @@ -993,6 +1004,7 @@ async def new(
base=False,
force=force,
no_linter=False,
no_base=False,
include=[],
)

Expand Down
6 changes: 3 additions & 3 deletions src/dipdup/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def get_typeclass_name(self, schema_path: Path) -> str: ...
async def init(
self,
force: bool = False,
base: bool = False,
no_linter: bool = False,
no_base: bool = False,
) -> None:
# NOTE: Package structure
self._package.initialize()

# NOTE: Common files
if base or self._include:
if not (env.NO_BASE or no_base):
_logger.info('Recreating base template with replay.yaml')
render_base(
answers=self._package.replay,
Expand All @@ -116,7 +116,7 @@ async def init(
await self.generate_handlers()
await self.generate_batch_handler()

if not env.NO_LINTER and not no_linter:
if not (env.NO_LINTER or no_linter):
self._package.format_lint()

async def generate_hooks(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/dipdup/dipdup.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,8 @@ def schema(self) -> Schema:
async def init(
self,
force: bool = False,
base: bool = False,
no_linter: bool = False,
no_base: bool = False,
include: set[str] | None = None,
) -> None:
"""Create new or update existing dipdup project"""
Expand Down Expand Up @@ -690,7 +690,7 @@ async def init(
)
await codegen.init(
force=force,
base=base,
no_base=no_base,
no_linter=no_linter,
)

Expand Down
3 changes: 3 additions & 0 deletions src/dipdup/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def reload_env() -> None:
MIGRATIONS, \
NEXT, \
NO_LINTER, \
NO_BASE, \
NO_SYMLINK, \
NO_VERSION_CHECK, \
PACKAGE_PATH, \
Expand All @@ -105,6 +106,7 @@ def reload_env() -> None:
MIGRATIONS = get_bool('DIPDUP_MIGRATIONS')
NEXT = get_bool('DIPDUP_NEXT')
NO_LINTER = get_bool('DIPDUP_NO_LINTER')
NO_BASE = get_bool('DIPDUP_NO_BASE')
NO_SYMLINK = get_bool('DIPDUP_NO_SYMLINK')
NO_VERSION_CHECK = get_bool('DIPDUP_NO_VERSION_CHECK')
PACKAGE_PATH = get_path('DIPDUP_PACKAGE_PATH')
Expand All @@ -126,6 +128,7 @@ def set_test() -> None:
MIGRATIONS: bool = get_bool('DIPDUP_MIGRATIONS')
NEXT: bool = get_bool('DIPDUP_NEXT')
NO_LINTER: bool = get_bool('DIPDUP_NO_LINTER')
NO_BASE: bool = get_bool('DIPDUP_NO_BASE')
NO_SYMLINK: bool = get_bool('DIPDUP_NO_SYMLINK')
NO_VERSION_CHECK: bool = get_bool('DIPDUP_NO_VERSION_CHECK')
PACKAGE_PATH: Path | None = get_path('DIPDUP_PACKAGE_PATH')
Expand Down