Skip to content
Kian Kyars edited this page Jul 8, 2025 · 1 revision
  • My assumption is that users will start a new project, import FLE, use env = gym.make("Lab") and then feed it some configuration, and use env.run() which would spin up the container (maybe pull down the image) and handle all of the complex handling. So the user wouldn't even need to know what was in the FLE codebase.
  • this sounds good apart from our current config.json setup requiring FLE codebase knowledge, and the aforementioned .env files. Please discuss this at tonights meeting

Best practices from other Python packages:


1. Config Files

  • Ship example configs as package data (e.g. config.example.yaml, default_config.json)
  • Expose a CLI command to copy these to the user’s working directory (e.g. mytool init or mytool config generate)
  • Allow user to override config location via CLI flag or env var (e.g. --config path/to/config.json or MYTOOL_CONFIG=...)
  • Use sensible defaults if config is missing

Examples:

  • mlflow: mlflow server --default-artifact-root ... (uses default config, can override)
  • dvc: dvc init creates .dvc/config
  • jupyter: jupyter notebook --generate-config creates ~/.jupyter/jupyter_notebook_config.py

2. .env and Environment Variables

  • Ship a .env.example or similar template
  • Document required variables in README and error messages
  • Load .env automatically (using python-dotenv) if present in CWD
  • Allow all config via env vars as fallback/override
  • Fail with clear error if required env vars are missing

Examples:

  • python-dotenv is used by many projects (e.g. openai, fastapi templates)
  • prefect and mlflow both support env var config

3. CLI Bootstrapping

  • Provide a CLI command to scaffold config and .env
    (e.g. mytool init or mytool setup)
  • Print next steps (e.g. “Edit .env and fill in your API keys”)

4. Summary Table

Practice Example Packages FLE Should...
Ship example configs jupyter, dvc, mlflow Include in package data
CLI to copy/init config jupyter, dvc Add fle init
.env template openai, fastapi Include .example.env
Auto-load .env openai, fastapi Use python-dotenv
Env var fallback mlflow, prefect Support for all config
Clear error on missing all good packages Print helpful error messages

TL;DR:

  • Ship example configs and .env in the package
  • Provide a CLI to scaffold/copy them
  • Auto-load .env, allow env var overrides
  • Print clear errors if missing

Clone this wiki locally