Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHodson committed Nov 12, 2024
1 parent 233889b commit 49c3e5c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
19 changes: 0 additions & 19 deletions config/docker_config.yaml

This file was deleted.

7 changes: 7 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
python -m ionbeam ./config -vvvv --env=local --init-db #--overwrite --offline

# To drop into a debugger on error, enable the -simple-output option first
# python -m ionbeam config/ionbeam -vvvv --offline --finish-after=5 --simple-output --debug

# Or just insert breakpoint() into the code and use --simple-output
4 changes: 4 additions & 0 deletions src/ionbeam/core/config_parser/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def parse_globals(config_dir: Path, **overrides):

# Based on the environment =dev/test/prod/local merge config into globals
env = overrides.get("environment", config.globals.environment)
if env is None:
logger.debug("No environment specified, defaulting to 'local'")
env = "local"

config.globals = merge_overlay(config.globals, config.environments[env])

# Merge config from the command line into the global config keys
Expand Down
11 changes: 5 additions & 6 deletions src/ionbeam/core/config_parser/config_parser_machinery.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from functools import cache
import dataclasses
from dataclasses import dataclass, field, Field
import dataclasses # So we can override is_dataclass and fields with a custom implementation
from typing import Union, get_origin, get_args, List
import typing
from dataclasses import Field, dataclass, field
from pathlib import Path
from typing import Union, get_args, get_origin

from .common import ConfigError, ConfigMatchError

# TYPE_KEY is a special key that determines which class or type to pick in ambiguous cases.
Expand Down Expand Up @@ -217,7 +216,7 @@ def parse_union(context, key, _type, value):
key,
_type,
value,
f"Union types of multiple non-dataclasses are not allowed"
"Union types of multiple non-dataclasses are not allowed"
" because there's no way to decide which one to use for parsing!",
)

Expand Down Expand Up @@ -319,7 +318,7 @@ def dataclass_from_dict(context, datacls, input_dict):

# initialise all the post_init fields to None, leaving it up to the caller to deal with them
post_init_fields = {field.name : None for field in fields(datacls)
if is_post_init_field(field) and not field.name in kwargs}
if is_post_init_field(field) and field.name not in kwargs}

return datacls(**kwargs, **post_init_fields)

Expand Down

0 comments on commit 49c3e5c

Please sign in to comment.