Skip to content

Commit b33c2b2

Browse files
new: Handle no config error
1 parent 77971e5 commit b33c2b2

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

deep_reference_parser/parse.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,20 @@ def __init__(self, config_file):
3333

3434
cfg = get_config(config_file)
3535

36+
# Build config
37+
try:
38+
OUTPUT_PATH = cfg["build"]["output_path"]
39+
S3_SLUG = cfg["data"]["s3_slug"]
40+
except KeyError:
41+
config_dir, missing_config = os.path.split(config_file)
42+
files = os.listdir(config_dir)
43+
other_configs = [f for f in os.listdir(config_dir) if os.path.isfile(os.path.join(config_dir, f))]
44+
msg.fail(f"Could not find config {missing_config}, perhaps you meant one of {other_configs}")
45+
3646
msg.info(
3747
f"Attempting to download model artefacts if they are not found locally in {cfg['build']['output_path']}. This may take some time..."
3848
)
3949

40-
# Build config
41-
42-
OUTPUT_PATH = cfg["build"]["output_path"]
43-
S3_SLUG = cfg["data"]["s3_slug"]
44-
4550
# Check whether the necessary artefacts exists and download them if
4651
# not.
4752

deep_reference_parser/split.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,20 @@ def __init__(self, config_file):
3737

3838
cfg = get_config(config_file)
3939

40+
# Build config
41+
try:
42+
OUTPUT_PATH = cfg["build"]["output_path"]
43+
S3_SLUG = cfg["data"]["s3_slug"]
44+
except KeyError:
45+
config_dir, missing_config = os.path.split(config_file)
46+
files = os.listdir(config_dir)
47+
other_configs = [f for f in os.listdir(config_dir) if os.path.isfile(os.path.join(config_dir, f))]
48+
msg.fail(f"Could not find config {missing_config}, perhaps you meant one of {other_configs}")
49+
4050
msg.info(
4151
f"Attempting to download model artefacts if they are not found locally in {cfg['build']['output_path']}. This may take some time..."
4252
)
4353

44-
# Build config
45-
46-
OUTPUT_PATH = cfg["build"]["output_path"]
47-
S3_SLUG = cfg["data"]["s3_slug"]
48-
4954
# Check whether the necessary artefacts exists and download them if
5055
# not.
5156

deep_reference_parser/split_parse.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ def __init__(self, config_file):
3737

3838
cfg = get_config(config_file)
3939

40-
msg.info(
41-
f"Attempting to download model artefacts if they are not found locally in {cfg['build']['output_path']}. This may take some time..."
42-
)
43-
44-
# Build config
45-
46-
OUTPUT_PATH = cfg["build"]["output_path"]
47-
S3_SLUG = cfg["data"]["s3_slug"]
40+
try:
41+
OUTPUT_PATH = cfg["build"]["output_path"]
42+
S3_SLUG = cfg["data"]["s3_slug"]
43+
except KeyError:
44+
config_dir, missing_config = os.path.split(config_file)
45+
files = os.listdir(config_dir)
46+
other_configs = [f for f in os.listdir(config_dir) if os.path.isfile(os.path.join(config_dir, f))]
47+
msg.fail(f"Could not find config {missing_config}, perhaps you meant one of {other_configs}")
4848

4949
# Check whether the necessary artefacts exists and download them if
5050
# not.

0 commit comments

Comments
 (0)