-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Working version for validate
command CLI
#152
Merged
+281
−30
Merged
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b0a7be7
first version of the JSON schema. Fixes issue #27
maximilien a35bc9c
Merge branch 'i-am-bee:main' into main
maximilien e287d40
addressing feedback from review
maximilien 8b230b6
addressed steps and agents definition
maximilien 91776e2
made agents also array
maximilien be36a00
first version of the agent schema that validares the agents used in POC0
maximilien 2626728
Merge branch 'i-am-bee:main' into main
maximilien 39cf195
added code section
maximilien 876f97c
included suggestions and changes from @akihikokuroda's PR #139 review…
maximilien a9b2597
Merge branch 'i-am-bee:main' into main
maximilien 286bbc5
Merge branch 'i-am-bee:main' into main
maximilien a452398
Merge branch 'i-am-bee:main' into main
maximilien b5d0f8d
[DRAFT] first PR for validate command and includes the Python CLI str…
maximilien a726ca0
fix correct CLI python file
maximilien 7e52f77
fix all the peotry issues by moving code to bee-hive cli directory. N…
maximilien d5e1c39
supress doctopt warnings and ignore bee-hive/poetry.lock
maximilien ff791f9
resolved conflict
maximilien d3befae
Merge branch 'maximilien-issue132'
maximilien 7fb7dbe
resolved conflicts ...
maximilien 2078464
moving to docopt-ng
maximilien 9f709f8
removing bee-hive/poetry.lock
maximilien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 @@ | ||
3.12.8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this needed |
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,3 @@ | ||
#!/bin/bash | ||
|
||
python3 ./cli/beeAI.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,43 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright © 2025 IBM | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""BeeAI | ||
|
||
Usage: | ||
beeAI validate SCHEMA_FILE YAML_FILE [options] | ||
|
||
beeAI (-h | --help) | ||
beeAI (-v | --version) | ||
|
||
Options: | ||
--verbose Show all output. | ||
|
||
-h --help Show this screen. | ||
-v --version Show version. | ||
|
||
""" | ||
import os, sys, traceback | ||
|
||
from docopt import docopt | ||
from cli import * | ||
|
||
if __name__ == '__main__': | ||
args = docopt(__doc__, version='beeAI CLI v0.0.0') | ||
command = CLI(args).command() | ||
rc = command.execute() | ||
if rc != 0: | ||
Console.error("executing command: {rc}".format(rc=rc)) | ||
sys.exit(rc) |
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,30 @@ | ||
# Copyright © 2025 IBM | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import io, sys | ||
|
||
from commands import * | ||
from common import * | ||
|
||
class CLI: | ||
def __init__(self, args): | ||
self.args = args | ||
if self.args['--verbose']: | ||
VERBOSE = True | ||
|
||
def command(self): | ||
if self.args.get('validate') and self.args['validate']: | ||
return Validate(self.args) | ||
else: | ||
raise Exception("Invalid command") |
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,78 @@ | ||
# Copyright © 2025 IBM | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import io, sys, yaml, json, jsonschema | ||
|
||
from common import Console | ||
|
||
# Base class for all commands | ||
class Command: | ||
def __init__(self, args): | ||
self.args = args | ||
|
||
def println(self, msg): | ||
self.print(msg + "\n") | ||
|
||
def print(self, msg): | ||
Console.print(msg) | ||
|
||
def warn(self, msg): | ||
Console.warn(msg) | ||
|
||
def verbose(self): | ||
return self.args['--verbose'] | ||
|
||
def execute(self): | ||
func = self.dispatch() | ||
rc = func() | ||
if rc == None: | ||
return 0 | ||
else: | ||
if isinstance(rc, int): | ||
return rc | ||
else: | ||
return 1 | ||
|
||
def dispatch(self): | ||
if self.args['validate']: | ||
return self.validate | ||
else: | ||
raise Exception("Invalid subcommand") | ||
|
||
# validate command group | ||
class Validate(Command): | ||
def __init__(self, args): | ||
self.args = args | ||
super().__init__(self.args) | ||
|
||
def SCHEMA_FILE(self): | ||
return self.args['SCHEMA_FILE'] | ||
|
||
def YAML_FILE(self): | ||
return self.args['SCHEMA_FILE'] | ||
|
||
def name(self): | ||
return "validate" | ||
|
||
def validate(self): | ||
Console.print("validate {yaml_file} with schema {schema_file}".format(yaml_file=self.YAML_FILE(), schema_file=self.SCHEMA_FILE())) | ||
with open(self.SCHEMA_FILE(), 'r') as f: | ||
schema = json.load(f) | ||
with open(self.YAML_FILE(), 'r') as f: | ||
yamls = yaml.safe_load_all(f) | ||
for yaml_data in yamls: | ||
json_data = json.dumps(yaml_data, indent=4) | ||
jsonschema.validate(yaml_data, schema) | ||
Console.print("YAML file is valid.") | ||
return 0 |
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,62 @@ | ||
# Copyright © 2025 IBM | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import sys | ||
from random import randint | ||
|
||
VERBOSE=False | ||
|
||
class Colors: | ||
HEADER = '\033[95m' | ||
OKBLUE = '\033[94m' | ||
OKGREEN = '\033[92m' | ||
WARNING = '\033[93m' | ||
FAIL = '\033[91m' | ||
ENDC = '\033[0m' | ||
BOLD = '\033[1m' | ||
UNDERLINE = '\033[4m' | ||
|
||
class Console: | ||
def verbose(msg): | ||
if VERBOSE: | ||
print(f"{Colors.OKBLUE}{msg}{Colors.ENDC}".format(msg=str(msg))) | ||
|
||
def print(msg=''): | ||
print(msg) | ||
|
||
def println(no=1): | ||
for i in range(no): | ||
print() | ||
|
||
def ok(msg): | ||
print(f"{Colors.OKGREEN}{msg}{Colors.ENDC}".format(msg=str(msg))) | ||
|
||
def error(msg): | ||
Console.fail(msg) | ||
|
||
def fail(msg): | ||
print(f"{Colors.FAIL}Error: {msg}{Colors.ENDC}".format(msg=str(msg))) | ||
|
||
def warn(msg): | ||
print(f"{Colors.WARNING}Warning: {msg}{Colors.ENDC}".format(msg=str(msg))) | ||
|
||
def progress(count, total, status=''): | ||
bar_len = 60 | ||
filled_len = int(round(bar_len * count / float(total))) | ||
|
||
percents = round(100.0 * count / float(total), 1) | ||
bar = '=' * filled_len + '-' * (bar_len - filled_len) | ||
|
||
sys.stdout.write('[%s] %s%s ...%s\r' % (bar, percents, '%', status)) | ||
sys.stdout.flush() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't make any difference (as per https://git-scm.com/docs/gitignore). A filename will apply at any level below. The file also appears lower down (which may be a dup)