Skip to content

Remove legacy code - #7585

Draft
agoscinski wants to merge 5 commits into
aiidateam:mainfrom
agoscinski:remove-legacy-code
Draft

Remove legacy code#7585
agoscinski wants to merge 5 commits into
aiidateam:mainfrom
agoscinski:remove-legacy-code

Conversation

@agoscinski

@agoscinski agoscinski commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

This simplifies the redesign of the ORM, because some parts of the fields logic is only required because of some renaming while keeping backwards compatibility. While this logic could be used in the future when a change with backwards compatibility is needed, I would rather not have this extra logic and wait for another major release to break things instead of having this backwards compatibility layer making the logic more complicated.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 38.98305% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.67%. Comparing base (56ad4d0) to head (5d57f06).

Files with missing lines Patch % Lines
...grations/versions/main_0003_migrate_legacy_code.py 0.00% 17 Missing ⚠️
...grations/versions/main_0002_migrate_legacy_code.py 0.00% 14 Missing ⚠️
src/aiida/restapi/translator/nodes/data/code.py 0.00% 3 Missing ⚠️
src/aiida/tools/visualization/graph.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7585      +/-   ##
==========================================
- Coverage   80.69%   80.67%   -0.02%     
==========================================
  Files         581      582       +1     
  Lines       47139    46915     -224     
==========================================
- Hits        38034    37842     -192     
+ Misses       9105     9073      -32     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Both classes subclassed the deprecated `Code` for history rather than for
behaviour: of its 36 methods they used only `__init__`, `_validate` and, for
`PortableCode`, a `get_executable` that they already override. Both already
called `super(Code, self)._validate()` to skip it, and both set
`_EMIT_CODE_DEPRECATION_WARNING = False` purely to silence `Code.__init__`.

Deriving them from `AbstractCode` directly drops all of that, along with the
`_SKIP_MODEL_INHERITANCE_CHECK` opt-out their nested models needed while
`Code` sat in the MRO.

`CodeEntityLoader` and `execmanager` queried on `Code` to resolve any code, so
they move to `AbstractCode`; `QueryBuilder` already widens an `AbstractCode`
filter to the shared `data.core.code` prefix, so `load_code` keeps finding
every code plugin.

The two `get_execname` tests are removed rather than adapted: the method is
part of the deprecated `Code` API and is not inherited any more.
Production storages contain nodes with `node_type = 'data.core.code.Code.'`.
Once the `core.code` entry point is gone, `load_node_class` would fall back to
`Data` for them without a word, so the codes would quietly lose their entire
API while still looking fine.

A stored legacy code already carries everything a modern one needs, so convert
it at the storage layer, where the data is, rather than at load time:

- `is_local=False` -> `InstalledCode`, `remote_exec_path` -> `filepath_executable`
- `is_local=True`  -> `PortableCode`,  `local_executable`  -> `filepath_executable`

Every other attribute uses the same key on `AbstractCode` and is left alone,
as are the repository contents a portable code needs. The node type and one
attribute key change, so `_aiida_hash` no longer describes the node and is
dropped; `verdi node rehash` recomputes it.

The same rewrite lands in all three storages: `psql_dos` and `sqlite_dos` as
`main_0003`, and the archive format as `main_0002`. Static archives that were
at the previous archive version are migrated along with it, two of which turn
out to contain exactly such a legacy code.
Deprecated since `aiida-core==2.1` and scheduled for removal in `3.0`. The
class and its `core.code` entry point are gone, along with the ~36 deprecated
methods it carried.

Everything that used `Code` to mean "any code" now uses `AbstractCode`: the
`verdi code` queries, the REST translator, the dumping filters and the
`verdi shell` auto-imports (which gain `InstalledCode` and `PortableCode`).
The graph visualisation special-cased the legacy node type for both its style
and its sublabel; it now covers the three concrete code types instead.

`load_node_class` raises `IncompatibleStorageSchema` for the legacy type
string rather than falling back to `Data`, so a storage that was never
migrated says so instead of silently degrading. The conversion itself belongs
to the storage migration and is not attempted here.

The archive importer's special case for the legacy type is dropped: it stripped
the `hidden` extra, which is a legitimate extra on the modern code plugins and
is preserved for them already.

`_KEY_ATTRIBUTE_DEFAULT_CALC_JOB_PLUGIN` and `_KEY_EXTRA_IS_HIDDEN` keep the
stored names they inherited from `Code`. Renaming them needs its own attribute
migration of every stored code, so that is left for a separate change and the
comments now say so.
The migration test files for the `psql_dos` and `sqlite_dos` backends share
the basename `test_main_0003_migrate_legacy_code.py`. Since neither directory
was a package, pytest resolved both to the same module name and failed to
collect the second one with an import file mismatch.

Add the missing `__init__.py` files, as is already done for the sibling
`psql_dos/migrations/django_branch` directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant