Skip to content

Commit

Permalink
refactor(optional artifact): remove unnecessary warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mostaphaRoudsari committed Mar 3, 2021
1 parent dc2f224 commit 26bc30b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
9 changes: 1 addition & 8 deletions queenbee/io/inputs/alias.py
Expand Up @@ -7,7 +7,6 @@
"""

import os
import warnings
from typing import Dict, Union, List

from pydantic import constr, Field, validator
Expand Down Expand Up @@ -302,14 +301,8 @@ class DAGFolderInputAlias(DAGGenericInputAlias):
)

@validator('required', always=True)
def check_required(cls, v, values):
def check_required(cls, v):
"""Overwrite check_required fro artifacts to allow optional artifacts."""
default = values.get('default', None)
name = values.get('name', None)
if default is None and v is False:
warnings.warn(
f'{cls.__name__}.{name} -> set to optional input artifact.'
)
return v

def validate_spec(self, value):
Expand Down
12 changes: 1 addition & 11 deletions queenbee/io/inputs/dag.py
@@ -1,7 +1,6 @@
"""Queenbee input types for a DAG."""

import os
import warnings
from typing import Dict, Union, List

from pydantic import constr, Field, validator
Expand Down Expand Up @@ -268,17 +267,8 @@ class DAGFolderInput(DAGGenericInput):
)

@validator('required', always=True)
def check_required(cls, v, values):
def check_required(cls, v):
"""Overwrite check_required fro artifacts to allow optional artifacts."""
if 'default' not in values:
return v
default = values.get('default')
name = values.get('name', None)
if default is None and v is False:
warnings.warn(
f'{cls.__name__}.{name} has no default value and is not required. '
'Set to optional input artifact.'
)
return v

def validate_spec(self, value):
Expand Down

0 comments on commit 26bc30b

Please sign in to comment.