PyPNM system configuration menu¶
Interactive Wrapper For Editing system.json Using Dedicated Helper Scripts.
This menu script provides a single entry point for all configuration helpers that
operate on the canonical PyPNM configuration file managed by ConfigManager.
- Menu Script:
tools/system_config/menu.py - Section Editors:
tools/system_config/*.py - File Setup Helper:
tools/pnm/pnm_file_retrieval_setup.py
Table of contents¶
Overview
Prerequisites
Launching-The-Menu
Menu-Options
Configuration-Path-Handling
Typical-Workflow
Related-Files
Overview¶
The PyPNM System Configuration Menu is a small interactive tool that wraps all
of the system.json editors into a single, easy-to-use interface.
Instead of remembering individual script names, you can launch one menu and select which configuration section you want to edit:
- Default FastAPI request parameters.
- SNMP settings.
- Bulk-data transfer settings.
- PNM file retrieval behavior.
- Logging options.
- TestMode flags.
- Initial PNM file-retrieval directory setup.
The menu script itself never modifies system.json directly. It only dispatches
to the underlying editor scripts, each of which shows the current values,
prompts for new ones, and asks for confirmation before writing anything.
Note: Because the menu shells out to the individual editors, any validation logic or confirmations live in those scripts. You can quit at any time before approving a change.
Prerequisites¶
- You are running from the project root, for example:
cd /path/to/PyPNM
- The virtual environment is activated (if you use one), for example:
source .env/bin/activate
src/is at the standard location so thatConfigManagercan resolve the canonical configuration file.
Tip: Activate the same virtual environment you use for
pypnmbefore launching the menu so the helper scripts inherit the correct dependencies and config paths.
Launching the menu¶
From the project root, run:
python tools/system_config/menu.py
You should see output similar to:
PyPNM System Configuration Menu
================================
Select an option:
1) Edit FastApiRequestDefault
2) Edit SNMP
3) Edit PnmBulkDataTransfer
4) Edit PnmFileRetrieval (retrieval_method only)
5) Edit PnmArtifactStorage
6) Edit Logging
7) Edit TestMode
8) Run PnmFileRetrieval Setup (directory initialization)
q) Quit
Enter selection:
The menu stays active until you choose q to quit.
Menu options¶
Each menu entry launches a dedicated script using the same Python interpreter
that invoked menu.py. The underlying scripts remain fully interactive and
preserve their own confirmation prompts.
1. Edit FastApiRequestDefault¶
- Script:
tools/system_config/fastapi_request_default.py - Config Section:
FastApiRequestDefault
This editor updates the default MAC address and IP address used by PyPNM FastAPI request models.
It will:
- Read the current
FastApiRequestDefaultvalues. - Prompt you for new values (press Enter to keep the existing ones).
- Show a JSON preview of the proposed section.
- Ask for confirmation before saving.
2. Edit SNMP¶
- Script:
tools/system_config/snmp.py - Config Section:
SNMP
This editor manages global SNMP settings, including:
- Top-level timeout.
- SNMP v2c enable/retries/communities.
- SNMP v3 enable/retries/security parameters.
As with other editors, you can:
- Press Enter to keep existing values.
- Change only the fields you care about.
- Review the final JSON subset before applying it.
3. Edit PnmBulkDataTransfer¶
- Script:
tools/system_config/pnm_bulk_data_transfer.py - Config Section:
PnmBulkDataTransfer
This editor updates the transport parameters used when a cable modem sends PNM files (RxMER, FEC Summary, etc.) to a server.
It allows you to modify:
- The preferred bulk method (
tftp,http, orhttps). - TFTP
ip_v4,ip_v6, andremote_dir. - HTTP/HTTPS
base_urlandportvalues.
Only the fields you explicitly change are updated; the rest of the section is preserved as-is.
4. Edit PnmFileRetrieval (retrieval_method only)¶
- Script:
tools/system_config/pnm_file_retrieval.py - Config Section:
PnmFileRetrieval.retrieval_method
This editor only touches the retrieval behavior, leaving all storage directories and JSON database paths unchanged.
It manages:
retrieval_method.methodretrieval_method.methods.local.src_dir
The prompt for the method uses the pipe-separated form:
Retrieval method (local | tftp | sftp | http | https)
This lets you switch between local-directory retrieval, TFTP, SFTP, or HTTP(S)-based retrieval without accidentally altering any of the PNM storage layout fields.
5. Edit PnmArtifactStorage¶
- Script:
tools/system_config/pnm_artifact_storage.py - Config Section:
PnmArtifactStorage
This editor updates compression policy and cache settings for artifact storage.
It supports:
- Compression enable/threshold settings.
- Compression lists (deny/always/conditional) using comma-separated input.
- Codec selection and levels.
- Cache root and subdirectory names.
- Cache TTLs and cleanup interval.
List prompts show the current values, for example:
Deny list (PNM types) [current: ds_ofdm_chan_est_coef] (comma-separated, Enter to keep):
6. Edit logging¶
- Script:
tools/system_config/logging_config.py - Config Section:
logging
This editor controls how PyPNM logs are written:
log_level(for exampleDEBUG,INFO,WARN,ERROR)log_dir(directory where logs are stored)log_filename(primary log file name)
It prints a small JSON preview of the updated logging section before asking
for confirmation.
7. Edit TestMode¶
- Script:
tools/system_config/testmode.py - Config Section:
TestMode
This editor manages the global and per-class TestMode flags used by PyPNM for synthetic/demo operation.
It supports:
- A global
TestMode.global.mode.enabletoggle. - A single per-class override per run via
TestMode.class_name.<Class>.mode.enable.
Typical usage:
- Turn on global TestMode for development.
- Optionally enable or disable TestMode for a specific class.
As with all editors, no changes are written until you confirm the proposed configuration.
8. Run PnmFileRetrieval setup (directory initialization)¶
- Script:
tools/pnm/pnm_file_retrieval_setup.py - Config Section(s): Reads
PnmFileRetrieval
This helper focuses on the filesystem side of PNM file handling. It reads
the PnmFileRetrieval configuration and ensures that the required directories
exist on disk (for example the .data/* folders configured for PNM binaries,
CSV, JSON, PNG, archives, and metadata).
Typical behavior:
- Inspect the configured PNM storage and database paths.
- Create any missing directories, preserving existing contents.
- Provide a summary of what was created or already present.
This script does not change system.json; it only reconciles the filesystem
with whatever configuration is already present.
Warning: Run the setup helper from the project root so the relative paths in
system.jsonresolve correctly; otherwise you may end up creating directories in unexpected locations.
Configuration path handling¶
All of the section editors and the setup helper ultimately operate on the same
configuration file used by the PyPNM runtime, resolved via ConfigManager.
The default path is derived from:
pypnm.config.config_manager.ConfigManager- Correct project layout (for example
src/pypnm/settings/system.json)
When you launch any editor from the menu, you will see a prompt similar to:
Path to system.json [<resolved-path>]:
You can:
- Press Enter to use the default path reported by
ConfigManager, or - Type a custom path (for example a staging or test configuration file).
This makes it easy to test changes on a copy of system.json before applying
them to a production configuration.
Typical workflow¶
A suggested flow when bringing up a new environment:
-
Verify FastAPI Defaults
Use option1to set a defaultmac_addressandip_addressappropriate for your lab device (for exampleaa:bb:cc:dd:ee:ffand192.168.0.100). -
Configure SNMP
Use option2to settimeout,retries, and the correct SNMP v2c or v3 credentials for your deployment. -
Configure Bulk Transfer
Use option3to make sure the modem sends PNM files to a reachable TFTP or HTTP(S) server. -
Configure File Retrieval Behavior
Use option4to selectlocalvstftp/sftp/http/httpsfor how PyPNM retrieves PNM files and to pointlocal.src_dirat the right directory when using local retrieval. -
Initialize PNM Directories
Use option7to run the PnmFileRetrieval setup helper, creating any missing.data/*directories referenced byPnmFileRetrieval. -
Tune Logging And TestMode
Use options5and6to control logging verbosity and TestMode behavior for development, integration testing, or demo environments.
Related files¶
Key files involved in the system configuration tooling:
-
src/pypnm/settings/system.json
Canonical configuration file loaded byConfigManagerand used by all PyPNM components. -
src/pypnm/config/config_manager.py
ImplementsConfigManager, which resolves the configuration path and exposes helpers for reading and writing the JSON file. -
tools/system_config/common.py
Shared helpers and base class used by all section editors, including prompt utilities and default-config-path resolution viaConfigManager. -
tools/system_config/menu.py
Interactive menu entry point that dispatches to each editor and the PNM file retrieval setup helper. -
tools/pnm/pnm_file_retrieval_setup.py
Directory and filesystem setup helper, ensuring the paths defined underPnmFileRetrievalexist on disk.