Skip to content

Commit

Permalink
fix(plugin): function cannot use . as input path
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineDao committed Sep 15, 2021
1 parent 46d556a commit 811c794
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
8 changes: 7 additions & 1 deletion queenbee/io/inputs/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import os
from typing import Union, List, Dict
from pydantic import constr, Field
from pydantic import constr, Field, validator
from jsonschema import validate as json_schema_validator

from .dag import DAGStringInput, DAGIntegerInput, DAGNumberInput, DAGBooleanInput, \
Expand Down Expand Up @@ -98,6 +98,12 @@ class FunctionFolderInput(DAGFolderInput):
' This path is relative to the working directory where the command is executed.'
)

@validator('path')
def not_workspace_path(cls, v):
if v == '.':
raise ValueError('Input path for a function file cannot be "."')
return v

@property
def referenced_values(self) -> Dict[str, List[str]]:
"""Get referenced variables if any
Expand Down
1 change: 1 addition & 0 deletions tests/assets/functions/invalid/invalid_input_path.error
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Input path for a function file cannot be "."
20 changes: 20 additions & 0 deletions tests/assets/functions/invalid/invalid_input_path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
type: Function
name: split-grid-from-folder
inputs:
- type: FunctionFolderInput
annotations: {}
name: input-grid
description: Path to sensor grids folder.
default:
alias: []
required: true
spec:
path: "."
outputs:
- type: FunctionFolderOutput
name: output-folder
description: Output folder with new sensor grids.
path: "."
required: true
command: honeybee-radiance grid split --folder . --log-file output/grids_info.json

0 comments on commit 811c794

Please sign in to comment.