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

Updates #1

Merged
merged 11 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ['3.8', '3.9', '3.10']
python: ['3.9', '3.10', '3.11']

steps:
- uses: compas-dev/compas-actions.build@v3
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
branches:
- main
- master

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,6 @@ temp/**
.vscode

docs/api/generated/
src/aixd_grasshopper/components/ghuser/

conda.recipe/
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In short, this is how that works.
3. Install development dependencies:

```bash
pip install -r requirements-dev.txt
pip install -e ".[dev]"
```

4. Make sure all tests pass:
Expand All @@ -21,7 +21,7 @@ In short, this is how that works.
invoke test
```

5. Start making your changes to the **master** branch (or branch off of it).
5. Start making your changes to the **main** branch (or branch off of it).
6. Make sure all tests still pass:

```bash
Expand All @@ -39,6 +39,7 @@ command line to ease recurring operations:
* `invoke check`: Run various code and documentation style checks.
* `invoke docs`: Generate documentation.
* `invoke test`: Run all tests and checks in one swift command.
* `invoke build-ghuser-components`: Build Grasshopper components.
* `invoke`: Show available tasks.

## Bug reports
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ include AUTHORS.md
include CHANGELOG.md
include requirements.txt

exclude requirements-dev.txt
exclude pytest.ini .bumpversion.cfg .editorconfig
exclude tasks.py
exclude CONTRIBUTING.md
Expand Down
73 changes: 71 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,73 @@
# aixd_grasshopper
# AI-eXtended Design (AIXD): Grasshopper plugin

Grasshopper plugin for the AIXD toolkit
Grasshopper plugin for the AIXD toolkit.

## Installation

#### Requirements:

- Python >= 3.9
- compas > 2.0
- flask

#### Latest stable version
Install `aixd_grasshopper` using `pip`
```
pip install aixd_grasshopper
```

Install `aixd_grasshopper` using `conda`:
```
conda install -c conda-forge aixd_grasshopper
```

**Note**: It is recommended to use virtual environments to manage the dependencies of your projects. If you are using
`conda`, you can create a new environment with `conda create -n myproject python=3.9` and then activate it with
`conda activate myproject` before installing `aixd_grasshopper`.

#### Latest unstable version

Install the latest version using `pip` from the git repository:
```
pip install --upgrade git+https://github.com/gramaziokohler/aixd_grasshopper.git
```

## Development

If you are going to develop on this repository, perform an installation from source:

```bash
git clone https://github.com/gramaziokohler/aixd_grasshopper.git
cd aixd_grasshopper
```

Then, install using conda, to install all the dependencies into a new environment called `aixd_gh`:
```bash
conda env create -f environment.yml
```

Or using pip:
```bash
pip install -e ".[dev]"
```

Finally, build Grasshopper components and install on Rhino/GH:

```bash
invoke build-ghuser-components
python -m compas_rhino.install -v 7.0
```

For more details on how the process of building components work, refer to [this docs](https://github.com/compas-dev/compas-actions.ghpython_components).

Check the [contribution guidelines](CONTRIBUTING.md) for more details.

## Folders and structure

The structure we follow on the current repo is as follows:

* `src` : for all source code.
* `src/aixd_grasshopper` : source code of `aixd_grasshopper` plugin.
* `src/aixd_grasshopper/components` : source code of the GH components.
* `src/aixd_grasshopper/ghuser_manual` : binary components, pre-built.
* `src/compas_aixd` : source code of the connector to COMPAS infrastructure.
11 changes: 11 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: aixd_gh
channels:
- conda-forge
dependencies:
- python=3.9
- compas >2,<3
- flask
- pip
- pip:
- -e ".[dev]"
prefix: "/opt/conda"
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[tool.black]
line-length = 120
extend-exclude = "src/aixd_grasshopper/components"

[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests", "src/aixd_grasshopper"]
testpaths = ["tests"]
python_files = [
"test_*.py",
"tests.py"
Expand Down
14 changes: 1 addition & 13 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
attrs >=17.4
black ==22.12.0
bump2version >=1.0.1
check-manifest >=0.36
compas_invocations
doc8
flake8
invoke >=0.14
isort
sphinx_compas2_theme
twine
wheel
-e .
-e ".[dev]"
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
aixd >=0.10.0
compas >2,<3
flask
21 changes: 18 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def read(*names, **kwargs):

long_description = read("README.md")
requirements = read("requirements.txt").split("\n")
optional_requirements = {}

setup(
name="aixd_grasshopper",
Expand Down Expand Up @@ -50,15 +49,31 @@ def read(*names, **kwargs):
],
keywords=[],
project_urls={},
packages=["aixd_grasshopper"],
packages=["aixd_grasshopper", "compas_aixd"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is "compas_aixd"?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is related to our need to hook up on the python -m compas_rhino.install step, the way we hook up to it is by declaring a few small plugins in our code. A plugin is just a function that can be automatically detected by compas to serve some function, there are different types but two of these types that we need are: 1) a plugin that will do declare which packages to make available inside rhino, and 2) what happens after install and uninstall (in our case, we install and uninstall the GH components respectively).

However, in order to detect plugins, compas has the requirement that the package name is prefixed with compas_. So, compas_aixd is basically an almost empty package that only contains the "pointers" to where the plugins mentioned before are located in aixd_grasshopper. You can identify the plugins because they are marked with a decorator (@compas.plugins.plugin).

package_dir={"": "src"},
package_data={},
data_files=[],
include_package_data=True,
zip_safe=False,
install_requires=requirements,
python_requires=">=3.8",
extras_require=optional_requirements,
extras_require={
"dev": [
"attrs >=17.4",
"black",
"bump2version >=1.0.1",
"check-manifest >=0.36",
"compas_invocations >=1.0.0",
"doc8",
"flake8",
"invoke >=0.14",
"isort",
"pytest >=6.0",
"sphinx_compas2_theme",
"twine",
"wheel",
],
},
entry_points={
"console_scripts": [],
},
Expand Down
19 changes: 8 additions & 11 deletions src/aixd_grasshopper/api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import base64

from flask import Flask, request


from controller import SessionController
import json
from compas.data import DataEncoder, DataDecoder

from compas.data import DataEncoder
from flask import Flask
from flask import request

from aixd_grasshopper.constants import default_port
from aixd_grasshopper.constants import DEFAULT_PORT
from aixd_grasshopper.controller import SessionController

app = Flask(__name__)

Expand Down Expand Up @@ -322,12 +319,12 @@ def model_input_output_dimensions():
import sys

if len(sys.argv) == 1:
port = default_port
port = DEFAULT_PORT
else:
try:
port = int(sys.argv[1])
except ValueError:
print("Invalid port number: ", sys.argv[1], "Setting a default port number {}".format(default_port))
port = default_port
print("Invalid port number: ", sys.argv[1], "Setting a default port number {}".format(DEFAULT_PORT))
port = DEFAULT_PORT

app.run(host="127.0.0.1", port=port, debug=False)
2 changes: 1 addition & 1 deletion src/aixd_grasshopper/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from __future__ import absolute_import
from __future__ import absolute_import
1 change: 1 addition & 0 deletions src/aixd_grasshopper/components/aixd_DataBool/code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
from aixd_grasshopper.wrappers import WrapperShallowDataObject

if not dim or dim < 1:
Expand Down
1 change: 1 addition & 0 deletions src/aixd_grasshopper/components/aixd_DataCat/code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
from aixd_grasshopper.wrappers import WrapperShallowDataObject

if not dim or dim < 1:
Expand Down
1 change: 1 addition & 0 deletions src/aixd_grasshopper/components/aixd_DataInt/code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
from aixd_grasshopper.wrappers import WrapperShallowDataObject

if not dim or dim < 1:
Expand Down
1 change: 1 addition & 0 deletions src/aixd_grasshopper/components/aixd_DataReal/code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
from aixd_grasshopper.wrappers import WrapperShallowDataObject

if not dim or dim < 1:
Expand Down
1 change: 1 addition & 0 deletions src/aixd_grasshopper/components/aixd_DatasetCreate/code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
from aixd_grasshopper.gh_ui import create_dataset_object
from aixd_grasshopper.gh_ui_helper import session_id, component_id
from scriptcontext import sticky as st
Expand Down
1 change: 1 addition & 0 deletions src/aixd_grasshopper/components/aixd_DatasetLoad/code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
from aixd_grasshopper.gh_ui import load_dataset
from aixd_grasshopper.gh_ui_helper import session_id, component_id
from scriptcontext import sticky as st
Expand Down
6 changes: 4 additions & 2 deletions src/aixd_grasshopper/components/aixd_DatasetOneSample/code.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from aixd_grasshopper.gh_ui import get_one_sample
from aixd_grasshopper.gh_ui_helper import session_id, component_id
# flake8: noqa
import Grasshopper

from aixd_grasshopper.gh_ui import get_one_sample
from aixd_grasshopper.gh_ui_helper import component_id
from aixd_grasshopper.gh_ui_helper import session_id

if not item:
item = -1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
from aixd_grasshopper.gh_ui import dataset_summary
from aixd_grasshopper.gh_ui_helper import session_id, component_id
from scriptcontext import sticky as st
Expand Down
1 change: 1 addition & 0 deletions src/aixd_grasshopper/components/aixd_GenSampleEval/code.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
summarytxt = {} # key =obj name, values= [req, pred, real]

request_dict = {}
Expand Down
Loading
Loading