Skip to content
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
merged 21 commits into from
Jan 30, 2025
Merged

Conversation

maximilien
Copy link
Collaborator

@maximilien maximilien commented Jan 29, 2025

This PR when complete will fix issue #132

  • DRAFT because having issues with poetry dependencies
  • Adds the Python CLI strucure
  • Adds the validate command

Quick test is:

./beeAI validate ./tools/workflow_schema.json ./test/schema/simple_workflow.yml

TODO

  • solve the poetry issues (could be my machine)
  • fix any issue since could not run code fully
  • add test for validate command
  • add basic test for CLI

CC: @psschwei and @akihikokuroda if you can take a look. I'll keep looking at how to resolve poetry

@maximilien maximilien self-assigned this Jan 29, 2025
@maximilien maximilien added the hive Multiagent orchestration label Jan 29, 2025
@planetf1
Copy link
Collaborator

What poetry issues do you have? @maximilien

  • Ensure you are using poetry version 2 or above
  • By default poetry will create a virtual environment outside the project tree. To work consistently with vscode etc I'd suggest poetry config settings.virtualenvs.in-project true (this is a user, not project, setting). This will result in a .venv in the project root (which is one level down from the github repo root).
  • Ensure you are in the bee-hive subdirectory when initially running these commands
  • Ensure poetry is installed globally, not just in a venv
  • I've only tested with python 3.12 . Our spec currently allows 3.11

beeAI Outdated Show resolved Hide resolved
common/common.py Outdated Show resolved Hide resolved
tools/cli/beeAI.py Show resolved Hide resolved
Copy link
Collaborator

@planetf1 planetf1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments above.

tools/cli/cli.py Outdated Show resolved Hide resolved
@planetf1
Copy link
Collaborator

planetf1 commented Jan 29, 2025

You WILL have poetry issues if using v1, make sure you have v2 installed (it is on homebrew)

To add additional dependencies:

  • cd bee-hive (the directory containing pyproject.yaml)
  • poetry shell << you can then run anything within this, as it will pick up virtual config. Run in each new shell
  • poetry add docopt << I found you needed this
  • poetry add common << and this
  • poetry install << will install the dependencies needed

Hopefully this will allow you to get code working. When merged I can open a subsequent PR to refactor & create a new module definition (in essence this would just add another directory alongside bee_hive, perhaps called bee_cli, perhaps bee_tools - but to have it 'under' where the pyproject.toml is)

@maximilien
Copy link
Collaborator Author

You WILL have poetry issues if using v1, make sure you have v2 installed (it is on homebrew)

To add additional dependencies:

  • cd bee-hive (the directory containing pyproject.yaml)
  • poetry shell << you can then run anything within this, as it will pick up virtual config. Run in each new shell
  • poetry add docopt << I found you needed this
  • poetry add common << and this
  • poetry install << will install the dependencies needed

Hopefully this will allow you to get code working. When merged I can open a subsequent PR to refactor & create a new module definition (in essence this would just add another directory alongside bee_hive, perhaps called bee_cli, perhaps bee_tools - but to have it 'under' where the pyproject.toml is)

OK. Will be trying this today,. Thanks for the tips Nigel. Heading to the office and I have a different machine so will try a clean setup there and see how far I get.

@maximilien maximilien added this to the POC1 milestone Jan 29, 2025
@maximilien maximilien linked an issue Jan 29, 2025 that may be closed by this pull request
…ow run CLI with: poetry run ./beeAI -h

You can run the validate command with: poetry run ./beeAI validate ../tools/workflow_schema.json ../test/schema/simple_workflow.yml
@maximilien maximilien changed the title [DRAFT] first upload for validate command CLI Working version for validate command CLI Jan 30, 2025
@maximilien
Copy link
Collaborator Author

@planetf1 this works now. Please check and give a review. Only thing missing are some tests but you can try the validate command with:

poetry run ./beeAI validate ../tools/workflow_schema.json ../test/schema/simple_workflow.yml

Assuming you are in thebee-hive/bee-hive directory. If this works let's merge as I can backfill missing test when I add the other commands.

Thanks for your suggestions and reviews.

CC: @psschwei @akihikokuroda

Copy link
Collaborator

@psschwei psschwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a rebase

Also, I got a number of syntax warnings for invalid escape sequence:

/.../python3.12/site-packages/docopt.py:165: SyntaxWarning: invalid escape sequence '\S'
  name = re.findall('(<\S*?>)', source)[0]
/.../python3.12/site-packages/docopt.py:166: SyntaxWarning: invalid escape sequence '\['
  value = re.findall('\[default: (.*)\]', source, flags=re.I)
/.../python3.12/site-packages/docopt.py:207: SyntaxWarning: invalid escape sequence '\['
  matched = re.findall('\[default: (.*)\]', description, flags=re.I)
/.../python3.12/site-packages/docopt.py:456: SyntaxWarning: invalid escape sequence '\S'

@planetf1
Copy link
Collaborator

@maximilien same comments as Paul - rebase + also get invalid escape sequences.
glad to see poetry works

@psschwei psschwei removed this from the POC1 milestone Jan 30, 2025
@maximilien
Copy link
Collaborator Author

/.../python3.12/site-packages/docopt.py:165: SyntaxWarning: invalid escape sequence '\S'
  name = re.findall('(<\S*?>)', source)[0]
...

I saw as well. I think this are issues with the doctopt depencies. I open issue #160

@maximilien
Copy link
Collaborator Author

@planetf1 solved all conflict and supress warnings for doctopt to move forward and will have solution in #160 in future. Please review and if all OK then merge.

NOTE: the checks are failing because I removed bee-hive/poetry.lock so that can be ignored

.gitignore Outdated Show resolved Hide resolved
@@ -105,7 +105,7 @@ ipython_config.py
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
Copy link
Collaborator

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)

@@ -11,6 +11,8 @@ python = ">= 3.11, < 3.13"
pyyaml = "^6.0.2"
openai = "^1.56.2"
python-dotenv = "^1.0.1"
docopt = "^0.6.2"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #160 - optional to do here in in a new PR (fix is to use docopt-ng)

@@ -0,0 +1,780 @@
# This file is automatically @generated by Poetry 2.0.1 and should not be changed by hand.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend removing this file from the PR. This needs to be explicit since it already forms part of the PR. Including means running poetry lock often & impacting CI tests (including it helps with reproducible builds, but I don't feel that's needed at this point)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will fix the test failure - other comments can be handled in additional issues/prs as needed

Copy link
Collaborator

@psschwei psschwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git rm bee-hive/bee-hive/poetry.lock but otherwise LGTM

@maximilien
Copy link
Collaborator Author

@planetf1 give me the OK to merge since #160 is tracking other issues with docopt

Assuming you are set with code. Will backfill tests with I work on #113 #114 and #115

Thanks.

@maximilien
Copy link
Collaborator Author

git rm bee-hive/bee-hive/poetry.lock but otherwise LGTM

Check now.

Copy link
Collaborator Author

@maximilien maximilien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if this is needed or should be added to gitignore? @planetf1 @psschwei

Copy link
Collaborator

@planetf1 planetf1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine for me now. thanks!

@planetf1
Copy link
Collaborator

@psschwei I don't see there's any further removal needed now
@maximilien There's already a .gitignore for poetry.lock (which applies to all subdirectories)

@@ -0,0 +1 @@
3.12.8
Copy link
Collaborator

@planetf1 planetf1 Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed
(optional to tidy up - or can be later PR)
Comes from pyenv?

@maximilien
Copy link
Collaborator Author

Ok let's merge. I was referring to: bee-hive/.python-version

@maximilien maximilien merged commit 4981b7b into i-am-bee:main Jan 30, 2025
1 check passed
@planetf1
Copy link
Collaborator

Ok let's merge. I was referring to: bee-hive/.python-version

Ah right, in that case, yes in another pr will need to remove, as well as add to .gitignore (can be just .python-version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hive Multiagent orchestration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI "validate" function for workflows
3 participants