|
11 | 11 | File,
|
12 | 12 | Directory,
|
13 | 13 | )
|
14 |
| - |
15 | 14 | import pydra
|
16 | 15 | from .helpers_file import template_update_single
|
17 | 16 | from ..utils.hash import hash_function
|
@@ -366,22 +365,33 @@ def check_metadata(self):
|
366 | 365 | if set(mdata.keys()) - supported_keys:
|
367 | 366 | raise AttributeError(
|
368 | 367 | f"only these keys are supported {supported_keys}, but "
|
369 |
| - f"{set(mdata.keys()) - supported_keys} provided" |
| 368 | + f"{set(mdata.keys()) - supported_keys} provided for '{fld.name}' " |
| 369 | + f"field in {self}" |
370 | 370 | )
|
371 | 371 | # checking if the help string is provided (required field)
|
372 | 372 | if "help_string" not in mdata:
|
373 |
| - raise AttributeError(f"{fld.name} doesn't have help_string field") |
374 |
| - # assuming that fields with output_file_template shouldn't have default |
375 |
| - if fld.default not in [attr.NOTHING, True, False] and mdata.get( |
376 |
| - "output_file_template" |
377 |
| - ): |
378 | 373 | raise AttributeError(
|
379 |
| - "default value should not be set together with output_file_template" |
| 374 | + f"{fld.name} doesn't have help_string field in {self}" |
380 | 375 | )
|
| 376 | + # assuming that fields with output_file_template shouldn't have default |
| 377 | + if mdata.get("output_file_template"): |
| 378 | + if fld.type not in (Path, ty.Union[Path, bool]): |
| 379 | + raise TypeError( |
| 380 | + f"Type of '{fld.name}' should be either pathlib.Path or " |
| 381 | + f"typing.Union[pathlib.Path, bool] (not {fld.type}) because " |
| 382 | + f"it has a value for output_file_template ({mdata['output_file_template']})" |
| 383 | + ) |
| 384 | + if fld.default not in [attr.NOTHING, True, False]: |
| 385 | + raise AttributeError( |
| 386 | + f"default value ({fld.default}) should not be set together with " |
| 387 | + f"output_file_template ({mdata['output_file_template']}) for " |
| 388 | + f"'{fld.name}' field in {self}" |
| 389 | + ) |
381 | 390 | # not allowing for default if the field is mandatory
|
382 | 391 | if not fld.default == attr.NOTHING and mdata.get("mandatory"):
|
383 | 392 | raise AttributeError(
|
384 |
| - "default value should not be set when the field is mandatory" |
| 393 | + f"default value ({fld.default}) should not be set when the field " |
| 394 | + f"('{fld.name}' in {self}) is mandatory" |
385 | 395 | )
|
386 | 396 | # setting default if value not provided and default is available
|
387 | 397 | if getattr(self, fld.name) is None:
|
@@ -571,7 +581,10 @@ def _field_metadata(
|
571 | 581 | )
|
572 | 582 | return callable_(**call_args_val)
|
573 | 583 | else:
|
574 |
| - raise Exception("(_field_metadata) is not a current valid metadata key.") |
| 584 | + raise Exception( |
| 585 | + f"Metadata for '{fld.name}', does not not contain any of the required fields " |
| 586 | + f'("callable", "output_file_template" or "value"): {fld.metadata}.' |
| 587 | + ) |
575 | 588 |
|
576 | 589 | def _check_requires(self, fld, inputs):
|
577 | 590 | """checking if all fields from the requires and template are set in the input
|
|
0 commit comments