Skip to content

Commit

Permalink
#1 cli
Browse files Browse the repository at this point in the history
  • Loading branch information
keniack committed Jul 8, 2020
1 parent 0e3ab7c commit 73efa78
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
5 changes: 3 additions & 2 deletions skippycli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ def skippy(debug):

@skippy.command()
@click.argument('args', nargs=-1)
def deploy(args):
@click.option('--config', default='skippy.yml')
def deploy(args, config):
logging.debug('reading skippy.yml')
logging.debug('arguments %s' % " ".join(args))
deploy_openfaas(args[0], "skippy.yml")
deploy_openfaas(args[0], config)


def main(*args, **kwargs):
Expand Down
21 changes: 11 additions & 10 deletions skippycli/commands/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,29 @@ def parse_yaml(config_file: str = None):
return yaml.safe_load(f)


def read_skippy_labels(config_file: str = None) -> Set[str]:
def read_skippy_labels(config_file: str = None):
config = parse_yaml(config_file)
skippy_labels = set()
skippy_labels.add(extract_label(_consume_label, config))
skippy_labels.add(extract_label(_produce_label, config))
skippy_labels.add(extract_label(_capability_label, config))
skippy_labels = list()
skippy_labels.extend(extract_label(_consume_label, config))
skippy_labels.extend(extract_label(_produce_label, config))
skippy_labels.extend(extract_label(_capability_label, config))
logging.info('Skippy labels %s' % skippy_labels)
return skippy_labels


def extract_label(label_suffix: str, data) -> Set[str]:
def extract_label(label_suffix: str, data):
label_arr = label_suffix.split('.')
value = data[label_arr[0]][label_arr[1]]
labels= set()
labels = list()
if isinstance(value, list):
# label_value = "[{}]".format(','.join(value))
for v in value:
print()

labels.append("{}{}.{}={}".format(_skippy_prefix, label_suffix, value.index(v), v))
else:
label_value = value
return "{}{}={}".format(_skippy_prefix, label_suffix, label_value)
labels.append("{}{}={}".format(_skippy_prefix, label_suffix, label_value))
logging.debug('labels %s' % labels)
return labels


def deploy_openfaas(deploy_cmd: str, config_file: str = None) -> None:
Expand Down
6 changes: 3 additions & 3 deletions tests/skippy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
data:
consume:
- myconsume1:myfile1
- myconsume2:myfile2
- myconsume1.myfile1
- myconsume2.myfile2
produce:
- myproduce1:myfile1
- myproduce1.myfile1
policy:
capability: gpu

0 comments on commit 73efa78

Please sign in to comment.