Skip to content

Commit

Permalink
Modernize the RACK cli packaging (#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy authored Aug 25, 2023
1 parent 6ea2506 commit 8d231ee
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 57 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/assemble-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('RACK/cli/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('RACK/cli/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
Expand Down Expand Up @@ -88,7 +88,6 @@ jobs:
run: |
cd RACK/cli
python3 -m pip install --upgrade pip setuptools wheel
pip3 wheel --wheel-dir=wheels -r requirements.txt
pip3 wheel --wheel-dir=wheels .
cd ${{ github.workspace }}
tar cfz RACK/rack-box/files/rack-cli.tar.gz RACK/cli/{*.sh,wheels}
Expand All @@ -112,7 +111,7 @@ jobs:
- name: Generate CDR files
shell: bash
run: |
pip3 install RACK/cli/wheels/*.whl
pip3 install --no-dependencies RACK/cli/wheels/*.whl
tar xfz RACK/rack-box/files/semtk.tar.gz semtk-opensource/standaloneExecutables/target/standaloneExecutables-jar-with-dependencies.jar
RACK/nodegroups/generate-cdrs.sh semtk-opensource/standaloneExecutables/target/standaloneExecutables-jar-with-dependencies.jar
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,20 @@ jobs:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('cli/dev/requirements.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('cli/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install RACK CLI development dependencies
run: pip3 install -q -r cli/dev/requirements.txt
run: |
pip3 install "cli/[dev]"
- name: Lint RACK CLI
run: |
cd cli
pylint .
mypy .
pylint rack
mypy rack
- name: Lint RACK Ontology
run: |
Expand Down Expand Up @@ -109,8 +110,7 @@ jobs:
- name: Run rack-box tests
run: |
cd RACK
pip3 install -r cli/requirements.txt
pip3 install cli/.
pip3 install cli/
pip3 install -r tests/requirements.txt
python3 -m pytest tests
Expand Down
2 changes: 1 addition & 1 deletion ScrapingToolKit/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ colorama
lxml
graphviz
ftfy
semtk-python3 @ git+https://github.com/ge-semtk/semtk-python3@d44a45941d06ec6466bbe61bfd81cd667d6a5137
semtk-python3 @ git+https://github.com/ge-semtk/semtk-python3@7995623e12e93b9b252200b9bd507949b8c0a430
8 changes: 4 additions & 4 deletions cli/dev/README.md → cli/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ are used to statically type-check the code. Usage is simple:

```shell
source venv/bin/activate
pip install -r dev/requirements.txt
mypy .
pip install ".[dev]"
mypy rack
```

## Tests
Expand All @@ -25,8 +25,8 @@ You can run the tests with `pytest`:

```shell
source venv/bin/activate
pip install -r dev/requirements.txt
python3 setup.py install && pytest
pip install ".[dev]"
pytest
```

Note that you should _always install the code before testing_.
Expand Down
6 changes: 2 additions & 4 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,15 @@ the RACK-Box README.
```shell
python3 -m venv venv
source venv/bin/activate
pip install --force -r requirements.txt
python3 setup.py install
pip3 install --force-reinstall .
```

If running on Windows, [GitBash](https://gitforwindows.org/) can be used with the following commands.

```shell
python -m venv venv
source venv/Scripts/activate
pip install --force -r requirements.txt
python setup.py install
pip3 install --force-reinstall .
```

## Initialize RACK-in-a-Box
Expand Down
8 changes: 0 additions & 8 deletions cli/dev/requirements.txt

This file was deleted.

48 changes: 48 additions & 0 deletions cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "rack"
version = "0.1"
description = "Command-line interface to RACK"
requires-python = ">=3.7"

dependencies = [
"ase==3.22.1",
"attrs==23.1.0",
"certifi==2023.7.22",
"chardet==5.1.0",
"colorama==0.4.6",
"idna==3.4",
"importlib-metadata==6.7.0",
"jsonschema==4.17.3",
"pyrsistent==0.19.3",
"python-dateutil==2.8.2",
"PyYAML==6.0",
"requests==2.31.0",
"Pillow==9.4.0",
"plotly==5.15.0",
"semtk-python3 @ git+https://github.com/ge-semtk/semtk-python3@7995623e12e93b9b252200b9bd507949b8c0a430",
"six==1.16.0",
"tabulate==0.9.0",
"urllib3==2.0.3",
"zipp==3.15.0",
]

optional-dependencies.dev = [
"mypy==1.0.0",
"pylint==2.16.2",
"pytest-docker==1.0.1",
"pytest==7.2.1",
"typed-ast==1.5.4",
"types-PyYAML==6.0.12.6",
"types-requests==2.28.11.13",
"types-tabulate==0.9.0.0",
]

[tool.setuptools]
packages = ["rack"]

[project.scripts]
rack = "rack.rack_cmd:main"
9 changes: 6 additions & 3 deletions cli/rack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,10 @@ def delete() -> None:
semtk3.delete_nodegroup_from_store(nodegroup)
delete()

def delete_store_item(id: str, item_type: str) -> None:
@with_status(f'Deleting {str_highlight(id)}')
def delete_store_item(ident: str, item_type: str) -> None:
@with_status(f'Deleting {str_highlight(ident)}')
def delete() -> None:
semtk3.delete_store_item(id, item_type)
semtk3.delete_store_item(ident, item_type)
delete()

def delete_nodegroups_driver(nodegroups: List[str], ignore_nonexistent: bool, yes: bool, use_regexp: bool, base_url: Url) -> None:
Expand Down Expand Up @@ -868,17 +868,20 @@ def dispatch_manifest_build(args: SimpleNamespace) -> None:

def dispatch_data_import(args: SimpleNamespace) -> None:
"""Implementation of the data import subcommand"""
global cliMethod
cliMethod = CLIMethod.DATA_IMPORT
ingest_data_driver(Path(args.config), args.base_url, args.model_graph, args.data_graph, args.triple_store, args.triple_store_type, args.clear)

def dispatch_data_cardinality(args: SimpleNamespace) -> None:
"""Implementation of the data cardinality subcommand"""
global cliMethod
cliMethod = CLIMethod.DATA_IMPORT
cardinality_driver(args.base_url, args.model_graph, args.data_graph, args.triple_store, args.triple_store_type,
export_format=args.format, headers=not args.no_headers, concise=args.concise, max_rows=args.max_rows)

def dispatch_model_import(args: SimpleNamespace) -> None:
"""Implementation of the plumbing model subcommand"""
global cliMethod
cliMethod = CLIMethod.MODEL_IMPORT
ingest_owl_driver(Path(args.config), args.base_url, args.model_graph, args.triple_store, args.triple_store_type, args.clear)

Expand Down
2 changes: 1 addition & 1 deletion cli/bin/rack → cli/rack/rack_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

logger = logging.getLogger(__name__)

if __name__ == "__main__":
def main() -> None:
# Sets up colors for Windows users
colorama.init()

Expand Down
19 changes: 0 additions & 19 deletions cli/requirements.txt

This file was deleted.

7 changes: 0 additions & 7 deletions cli/setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion rack-box/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,5 @@ done
# Setup the RACK dataset using the RACK CLI

cd "/home/${USER}/RACK/cli/"
python3 -m pip install ./wheels/*.whl
python3 -m pip install --no-dependencies ./wheels/*.whl
./setup-rack.sh

0 comments on commit 8d231ee

Please sign in to comment.