-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added program to evaluate and dockerfile
- Loading branch information
1 parent
b321d3a
commit 8a69948
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM python:3-slim | ||
|
||
COPY find_oph_workflows.py /usr/bin | ||
|
||
RUN chmod +x /usr/bin/find_oph_workflows.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from PyOphidia import client | ||
import os | ||
import json | ||
import argparse | ||
|
||
|
||
def find(pattern, path): | ||
result = [] | ||
for root, dirs, files in os.walk(path): | ||
for name in files: | ||
if pattern in name: | ||
result.append(os.path.join(root, name)) | ||
return result | ||
|
||
|
||
def get_input_args(): | ||
parser = argparse.ArgumentParser(description=("Find Ophidia workflows")) | ||
parser.add_argument( | ||
"--path", metavar="PATH", type=str, help="path to look for in the repository" | ||
) | ||
return parser.parse_args() | ||
|
||
|
||
def evaluate_workflow(candidates): | ||
ophclient = client.Client( | ||
username="oph-user", password="oph-passwd", local_mode=True | ||
) | ||
passed = 0 | ||
passed_list = [] | ||
failed_list = [] | ||
for jsons in candidates: | ||
f = open(str(jsons), "r") | ||
|
||
data = json.load(f) | ||
res, msg = ophclient.wisvalid(data) | ||
|
||
if res: | ||
passed = True | ||
passed_list.append(jsons) | ||
else: | ||
failed_list.append(jsons) | ||
|
||
results = { | ||
"result": passed, | ||
"passed_list": passed_list, | ||
"failed_list": failed_list, | ||
} | ||
return results | ||
|
||
|
||
def main(): | ||
|
||
args = get_input_args() | ||
candid = find(".json", args.path) | ||
res = evaluate_workflow(candid) | ||
return json.dumps(res) | ||
|
||
|
||
print(main()) |