Skip to content
Kian Kyars edited this page Jul 8, 2025 · 3 revisions

Package Structure After Changes

factorio-learning-environment/
├── fle/
│   ├── __init__.py
│   ├── run.py
│   └── cluster/local/run-envs.sh  # INCLUDED
├── .example.env  # INCLUDED
└── pyproject.toml
# 1. Install package
uv add factorio-learning-environment

# 2. Initialize workspace (copies configs, creates .env)
fle init

# 3. Setup Docker containers  
fle cluster

# 4. Run experiment
fle run --run_config=run_config_example_open_play.json

Package data access:

import importlib.resources

def get_package_data():
    with importlib.resources.files('fle') as pkg:
        return {
            'env_template': pkg / '.example.env',
            'run_configs': pkg / 'eval' / 'algorithms' / 'independent',
            'task_defs': pkg / 'eval' / 'tasks' / 'task_definitions',
        }

CLI init command:

@cli.command()
def init():
    """Initialize FLE workspace"""
    # Create .fle directory
    Path('.fle').mkdir(exist_ok=True)
    
    # Copy .env template
    if not Path('.env').exists():
        shutil.copy(get_package_data()['env_template'], '.env')
        click.echo("Created .env file - please edit with your API keys")
    
    # Copy example configs
    config_dir = Path('configs')
    config_dir.mkdir(exist_ok=True)
    
    for config in get_package_data()['run_configs'].glob('run_config_example_*.json'):
        shutil.copy(config, config_dir / config.name)
    
    click.echo("FLE workspace initialized!")
``

Clone this wiki locally