Introduce YAML configuration file for deployment-specific settings #29

Open
opened 2026-02-16 16:47:11 +00:00 by forbes · 0 comments
Owner

Summary

The addon has no external configuration file. All deployment-specific values are either hardcoded as Python literals or stored in FreeCAD's XML preference system. This makes it difficult for administrators to pre-configure deployments, manage fleet-wide settings, or use the silo-client submodule from non-FreeCAD applications that lack FreeCAD's preference infrastructure.

A YAML configuration file (e.g. silo.yaml) would provide a single, human-readable source of truth for values that vary per deployment.

Current State

No YAML files exist anywhere in the repository. No yaml/pyyaml imports are present. Configuration is split across:

  1. FreeCAD XML preferences (ParamGet) — API URL, token, SSL settings, projects dir
  2. Environment variables — SILO_API_URL, SILO_API_TOKEN, SILO_PROJECTS_DIR
  3. Hardcoded Python literals — schema name, domain labels, item types, sourcing types, revision statuses, timeouts, file extensions, subdirectory names

Values That Should Move to YAML

Domain / Schema Configuration

  • Schema name (currently hardcoded "kindred-rd" — see #28)
  • _DOMAIN_LABELS dict mapping category prefixes to human labels (schema_form.py:19-30)
  • _ITEM_TYPES: ["part", "assembly", "consumable", "tool"] (schema_form.py:32)
  • _SOURCING_TYPES: ["manufactured", "purchased"] (schema_form.py:33)
  • _KNOWN_DEFAULTS: 12 "common" property names (schema_form.py:459-472)
  • Revision statuses: ["draft", "review", "released", "obsolete"] (silo_commands.py:1652)

Timing / Network

  • HTTP timeouts: 5s (schema), 10s (ready/diag), 90s (SSE)
  • SSE reconnection: _MAX_RETRIES=10, _BASE_DELAY=1, _MAX_DELAY=60
  • UI debounce: 300-500ms across multiple files
  • Refresh intervals: 30-60s across multiple files
  • Overlay registration delay: 2500ms

Paths / Extensions

  • Default projects directory: ~/projects
  • CAD subdirectory: "cad"
  • Preferred file extension: ".kc"

Proposed Config File Structure

# silo.yaml — Kindred Silo deployment configuration

schema: kindred-rd

domain:
  labels:
    F: Fastener
    C: Connector
    R: Raw Material
    S: Structural
    E: Electrical
    M: Mechanical
    T: Thermal
    A: Accessory
    P: Packaging
    X: Miscellaneous
  item_types: [part, assembly, consumable, tool]
  sourcing_types: [manufactured, purchased]
  revision_statuses: [draft, review, released, obsolete]

paths:
  projects_dir: ~/projects
  cad_subdir: cad
  file_extension: .kc

timeouts:
  http_default: 10
  schema_fetch: 5
  sse_stream: 90
  sse_max_retries: 10
  sse_base_delay: 1
  sse_max_delay: 60

ui:
  debounce_ms: 500
  refresh_interval_ms: 30000
  overlay_delay_ms: 2500

Config File Resolution Order

  1. Path specified by SILO_CONFIG environment variable
  2. silo.yaml in the addon directory (next to freecad/)
  3. ~/.config/kindred/silo.yaml (XDG user config)
  4. Built-in defaults (current hardcoded values, for backwards compatibility)

Proposed Implementation

  1. Add pyyaml as a dependency (or use a minimal YAML parser to avoid the dependency).
  2. Create a config.py module that loads and merges the YAML config with defaults.
  3. Expose config values through a simple API (e.g. config.get("schema"), config.timeouts.http_default).
  4. Replace all hardcoded literals with config lookups.
  5. FreeCAD preferences should override YAML values where both exist (preferences are user-level, YAML is deployment-level).
  6. Ship a commented silo.yaml.example with all defaults documented.

Acceptance Criteria

  • A YAML config file is loaded at startup with a documented resolution order
  • All domain-specific literals are read from config with sensible defaults
  • All timing constants are read from config
  • FreeCAD preferences still override config values where applicable
  • A silo.yaml.example is shipped with documented defaults
  • The config module is usable by non-FreeCAD consumers of silo-client
## Summary The addon has no external configuration file. All deployment-specific values are either hardcoded as Python literals or stored in FreeCAD's XML preference system. This makes it difficult for administrators to pre-configure deployments, manage fleet-wide settings, or use the `silo-client` submodule from non-FreeCAD applications that lack FreeCAD's preference infrastructure. A YAML configuration file (e.g. `silo.yaml`) would provide a single, human-readable source of truth for values that vary per deployment. ## Current State **No YAML files exist** anywhere in the repository. No `yaml`/`pyyaml` imports are present. Configuration is split across: 1. FreeCAD XML preferences (`ParamGet`) — API URL, token, SSL settings, projects dir 2. Environment variables — `SILO_API_URL`, `SILO_API_TOKEN`, `SILO_PROJECTS_DIR` 3. Hardcoded Python literals — schema name, domain labels, item types, sourcing types, revision statuses, timeouts, file extensions, subdirectory names ## Values That Should Move to YAML ### Domain / Schema Configuration - Schema name (currently hardcoded `"kindred-rd"` — see #28) - `_DOMAIN_LABELS` dict mapping category prefixes to human labels (`schema_form.py:19-30`) - `_ITEM_TYPES`: `["part", "assembly", "consumable", "tool"]` (`schema_form.py:32`) - `_SOURCING_TYPES`: `["manufactured", "purchased"]` (`schema_form.py:33`) - `_KNOWN_DEFAULTS`: 12 "common" property names (`schema_form.py:459-472`) - Revision statuses: `["draft", "review", "released", "obsolete"]` (`silo_commands.py:1652`) ### Timing / Network - HTTP timeouts: 5s (schema), 10s (ready/diag), 90s (SSE) - SSE reconnection: `_MAX_RETRIES=10`, `_BASE_DELAY=1`, `_MAX_DELAY=60` - UI debounce: 300-500ms across multiple files - Refresh intervals: 30-60s across multiple files - Overlay registration delay: 2500ms ### Paths / Extensions - Default projects directory: `~/projects` - CAD subdirectory: `"cad"` - Preferred file extension: `".kc"` ## Proposed Config File Structure ```yaml # silo.yaml — Kindred Silo deployment configuration schema: kindred-rd domain: labels: F: Fastener C: Connector R: Raw Material S: Structural E: Electrical M: Mechanical T: Thermal A: Accessory P: Packaging X: Miscellaneous item_types: [part, assembly, consumable, tool] sourcing_types: [manufactured, purchased] revision_statuses: [draft, review, released, obsolete] paths: projects_dir: ~/projects cad_subdir: cad file_extension: .kc timeouts: http_default: 10 schema_fetch: 5 sse_stream: 90 sse_max_retries: 10 sse_base_delay: 1 sse_max_delay: 60 ui: debounce_ms: 500 refresh_interval_ms: 30000 overlay_delay_ms: 2500 ``` ## Config File Resolution Order 1. Path specified by `SILO_CONFIG` environment variable 2. `silo.yaml` in the addon directory (next to `freecad/`) 3. `~/.config/kindred/silo.yaml` (XDG user config) 4. Built-in defaults (current hardcoded values, for backwards compatibility) ## Proposed Implementation 1. Add `pyyaml` as a dependency (or use a minimal YAML parser to avoid the dependency). 2. Create a `config.py` module that loads and merges the YAML config with defaults. 3. Expose config values through a simple API (e.g. `config.get("schema")`, `config.timeouts.http_default`). 4. Replace all hardcoded literals with config lookups. 5. FreeCAD preferences should **override** YAML values where both exist (preferences are user-level, YAML is deployment-level). 6. Ship a commented `silo.yaml.example` with all defaults documented. ## Acceptance Criteria - [ ] A YAML config file is loaded at startup with a documented resolution order - [ ] All domain-specific literals are read from config with sensible defaults - [ ] All timing constants are read from config - [ ] FreeCAD preferences still override config values where applicable - [ ] A `silo.yaml.example` is shipped with documented defaults - [ ] The config module is usable by non-FreeCAD consumers of `silo-client`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo-mod#29