Skip to content

Commit

Permalink
Add lint warnings for nonsensical Task configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Nov 1, 2023
1 parent 17983ed commit fe56ac4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/warning_examples/nonsensical-task-bits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- step:
name: train
image: tensorflow/tensorflow
command: python -u /tmp/code/my_mnist.py
parameters:
- name: A
type: integer
default: 1
- task:
step: run training
name: task
type: grid-search
parameters:
- name: A
style: single
rules:
value: 25
optimization-target-metric: goodness
optimization-target-value: 7.2
10 changes: 10 additions & 0 deletions valohai_yaml/objs/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,13 @@ def parse(cls, data: Any) -> Task:
def lint(self, lint_result: LintResult, context: LintContext) -> None:
context = dict(context, task=self, object_type="task")
lint_expression(lint_result, context, "stop-condition", self.stop_condition)
if self.type != TaskType.BAYESIAN_TPE:
for key in (
"optimization_target_value",
"optimization_target_metric",
"engine",
):
if getattr(self, key) is not None:
lint_result.add_warning(
f"{key} only makes sense for Bayesian TPE tasks",
)

0 comments on commit fe56ac4

Please sign in to comment.