Codebase dedublication and Cleanup refactor Documentation updated as well Preferences update Removed testfiles from repository
9.7 KiB
9.7 KiB
Developer Guide: Codebase Structure
This document outlines the key files and directories within the Asset Processor Tool project.
Asset_processor_tool/
├── configuration.py # Class for loading and accessing configuration (merges app_settings.json and presets)
├── Dockerfile # Instructions for building the Docker container image
├── main.py # Main application entry point (primarily GUI launcher)
├── monitor.py # Directory monitoring script for automated processing (async)
├── processing_engine.py # Core class handling single asset processing based on SourceRule
├── requirements-docker.txt # Dependencies specifically for the Docker environment
├── requirements.txt # Python package dependencies for standard execution
├── rule_structure.py # Dataclasses for hierarchical rules (SourceRule, AssetRule, FileRule)
├── blenderscripts/ # Scripts for integration with Blender
│ ├── create_materials.py # Script to create materials linking to node groups
│ └── create_nodegroups.py # Script to create node groups from processed assets
├── config/ # Directory for configuration files
│ ├── app_settings.json # Core settings, constants, and type definitions
│ └── suppliers.json # Persistent list of known supplier names for GUI auto-completion
├── Deprecated/ # Contains old code, documentation, and POC scripts
│ ├── ...
├── Documentation/ # Directory for organized documentation (this structure)
│ ├── 00_Overview.md
│ ├── 01_User_Guide/
│ └── 02_Developer_Guide/
├── gui/ # Contains files related to the Graphical User Interface (PySide6)
│ ├── asset_restructure_handler.py # Handles model updates for target asset changes
│ ├── base_prediction_handler.py # Abstract base class for prediction logic
│ ├── config_editor_dialog.py # Dialog for editing configuration files
│ ├── delegates.py # Custom delegates for inline editing in rule view
│ ├── llm_interaction_handler.py # Manages communication with LLM service
│ ├── llm_prediction_handler.py # LLM-based prediction handler
│ ├── log_console_widget.py # Widget for displaying logs
│ ├── main_panel_widget.py # Main panel containing core GUI controls
│ ├── main_window.py # Main GUI application window (coordinator)
│ ├── prediction_handler.py # Rule-based prediction handler
│ ├── preset_editor_widget.py # Widget for managing presets
│ ├── preview_table_model.py # Model for the (deprecated?) preview table
│ ├── rule_editor_widget.py # Widget containing the rule hierarchy view and editor
│ ├── rule_hierarchy_model.py # Internal model for rule hierarchy data
│ └── unified_view_model.py # QAbstractItemModel for the rule hierarchy view
├── llm_prototype/ # Files related to the experimental LLM predictor prototype
│ ├── ...
├── Presets/ # Preset definition files (JSON)
│ ├── _template.json # Template for creating new presets
│ ├── Poliigon.json # Example preset for Poliigon assets
│ └── ... # Other presets
├── ProjectNotes/ # Directory for developer notes, plans, etc. (Markdown files)
│ ├── ...
├── PythonCheatsheats/ # Utility Python reference files
│ ├── ...
├── Testfiles/ # Directory containing example input assets for testing
│ ├── ...
├── Tickets/ # Directory for issue and feature tracking (Markdown files)
│ ├── ...
└── utils/ # Utility modules shared across the application
├── prediction_utils.py # Utilities for prediction (e.g., used by monitor)
└── workspace_utils.py # Utilities for managing processing workspaces
Key Files and Directories:
config/: Directory containing configuration files.app_settings.json: Stores global default settings, constants, core rules, and centralized definitions for allowed asset and file types (ASSET_TYPE_DEFINITIONS,FILE_TYPE_DEFINITIONS) used for validation, GUI elements, and coloring. Replaces the oldconfig.py.suppliers.json: A JSON file storing a persistent list of known supplier names, used by the GUI for auto-completion.
configuration.py: Defines theConfigurationclass. Responsible for loading core settings fromconfig/app_settings.jsonand merging them with a specified preset JSON file (Presets/*.json). Pre-compiles regex patterns from presets for efficiency. An instance of this class is passed to theProcessingEngine.rule_structure.py: Defines theSourceRule,AssetRule, andFileRuledataclasses. These structures represent the hierarchical processing rules and are the primary data contract passed from the rule generation layer (GUI, Monitor) to the processing engine.processing_engine.py: Defines theProcessingEngineclass. This is the core component that executes the processing pipeline for a single asset based solely on a providedSourceRuleobject and the staticConfiguration. It contains no internal prediction or fallback logic.main.py: Main entry point for the application. Primarily responsible for initializing and launching the GUI (gui.main_window.MainWindow). Contains non-functional/commented-out CLI logic (run_cli).monitor.py: Implements the automated directory monitoring feature usingwatchdog. It now processes detected archives asynchronously using aThreadPoolExecutor. It utilizesutils.prediction_utils.generate_source_rule_from_archivefor rule-based prediction andutils.workspace_utils.prepare_processing_workspacefor workspace setup before invoking theProcessingEngine.gui/: Directory containing all code related to the Graphical User Interface (GUI), built with PySide6. TheMainWindowacts as a coordinator, delegating functionality to specialized widgets and handlers.main_window.py: Defines theMainWindowclass. Acts as the main application window and coordinator, connecting signals and slots between different GUI components.main_panel_widget.py: DefinesMainPanelWidget, containing the primary user controls (source loading, preset selection, rule view/editor integration, processing buttons).preset_editor_widget.py: DefinesPresetEditorWidgetfor managing presets (loading, saving, editing).log_console_widget.py: DefinesLogConsoleWidgetfor displaying application logs within the GUI.rule_editor_widget.py: DefinesRuleEditorWidget, which houses theQTreeViewfor displaying the rule hierarchy.unified_view_model.py: DefinesUnifiedViewModel(QAbstractItemModel) for the rule hierarchy view. HoldsSourceRuledata, manages display logic (coloring), handles inline editing requests, and caches configuration data for performance.rule_hierarchy_model.py: DefinesRuleHierarchyModel, a simpler internal model used byUnifiedViewModelto manage the underlyingSourceRuledata structure.delegates.py: Contains customQStyledItemDelegateimplementations used by theUnifiedViewModelto provide appropriate inline editors (e.g., dropdowns, text boxes) for different rule attributes.asset_restructure_handler.py: DefinesAssetRestructureHandler. Handles the complex logic of modifying theSourceRulehierarchy when a user changes a file's target asset via the GUI, ensuring data integrity. Triggered by signals from the model.base_prediction_handler.py: Defines the abstractBasePredictionHandlerclass, providing a common interface and threading (QRunnable) for prediction tasks.prediction_handler.py: DefinesRuleBasedPredictionHandler(inherits fromBasePredictionHandler). Generates the initialSourceRulehierarchy with predicted values based on input files and the selected preset rules. Runs in a background thread.llm_prediction_handler.py: DefinesLLMPredictionHandler(inherits fromBasePredictionHandler). Experimental handler using an LLM for prediction. Runs in a background thread.llm_interaction_handler.py: DefinesLLMInteractionHandler. Manages the communication details (API calls, etc.) with the LLM service, used byLLMPredictionHandler.
utils/: Directory containing shared utility modules.workspace_utils.py: Provides functions for managing processing workspaces, such as creating temporary directories and extracting archives (prepare_processing_workspace). Used bymain.py(ProcessingTask) andmonitor.py.prediction_utils.py: Provides utility functions related to prediction, such as generating aSourceRulefrom an archive (generate_source_rule_from_archive), used bymonitor.py.
blenderscripts/: Contains Python scripts (create_nodegroups.py,create_materials.py) designed to be executed within Blender for post-processing.Presets/: Contains supplier-specific configuration files in JSON format, used by theRuleBasedPredictionHandlerfor initial rule generation.Testfiles/: Contains example input assets for testing purposes.Tickets/: Directory for issue and feature tracking using Markdown files.Deprecated/: Contains older code, documentation, and proof-of-concept scripts that are no longer actively used.