Repository navigation
Enhancements for recort import/export - #11630
Conversation
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
There was a problem hiding this comment.
Pull request overview
Adds metadata capture and compatibility validation to the database import/export invoke tasks to improve backup/restore reliability when plugin-provided apps/models are involved (per #11235).
Changes:
- Add export-time metadata header (version/commit/timestamp/installed apps) to exported fixture JSON.
- Add import-time preprocessing to strip metadata and validate compatibility (version + installed apps), with optional strict mode.
- Introduce a
list_appsDjango management command and wire it into the invoke tasks and schema-generation exclusions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tasks.py |
Adds version helper functions, app listing via list_apps, export metadata injection, and import validation/flags. |
src/backend/InvenTree/InvenTree/ready.py |
Excludes list_apps from schema-generation detection. |
src/backend/InvenTree/InvenTree/management/commands/list_apps.py |
New management command to output installed app list in a parseable format. |
Comments suppressed due to low confidence (1)
tasks.py:315
builtin_apps()contains a duplicate entry for'machine'in the returned list. This can cause duplicate test targets (and redundant work) when buildingtested_apps. Remove the duplicate (and consider updating the docstring to clarify these are built-in apps used for testing, not the full installed app list).
def builtin_apps():
"""Returns a list of installed apps."""
return [
'build',
'common',
'company',
'importer',
'machine',
'order',
'part',
'report',
'stock',
'users',
'plugin',
'InvenTree',
'generic',
'machine',
'web',
]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| def installed_apps(c) -> list[str]: | ||
| """Returns a list of all installed apps, including plugins.""" | ||
| result = manage(c, 'list_apps', pty=False, hide=True) |
There was a problem hiding this comment.
Why not directly handoff the data? Going over the shell just adds failure states;
Via call_command
There was a problem hiding this comment.
Because tasks.py is not within the scope of the manage.py script, it does not operate within the correct django environment:
e.g.
def installed_apps(c) -> list[str]:
"""Returns a list of all installed apps, including plugins."""
from django.core.management import call_command
output = call_command('list_apps', stdout=subprocess.PIPE).getvalue().decode('utf-8').strip()throws:
Traceback (most recent call last):
File "/home/inventree/dev/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 110, in call_command
app_name = get_commands()[command_name]
~~~~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'list_apps'There was a problem hiding this comment.
Pretty sure this will break in unexpected ways depending on the local shell environment but we will see
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #11630 +/- ##
==========================================
- Coverage 91.44% 91.35% -0.10%
==========================================
Files 962 962
Lines 49783 49836 +53
==========================================
+ Hits 45524 45527 +3
- Misses 4259 4309 +50
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
* Add management command to list installed apps * Add metadata to exported data file * Validate metadata for imported file * Update CHANGELOG.md * Update docs * Use internal codes * Refactor and add more metadata * Adjust github action workflow * Run with --force option to setup demo dataset
This PR is the first step towards supporting sequential data import to allow migration of a setup which has plugins which have defined database models - #11235
import_recordsandexport_recordscommandsDuring Export
During Import