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

feat (cli): initialize the CLI of GraphAr and support baseETL functions #616

Merged
merged 35 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
25ea334
init cli
jasinliu Sep 3, 2024
a8da3ce
fix include
jasinliu Sep 5, 2024
c17de46
Merge branch 'main' of https://github.com/apache/incubator-graphar in…
jasinliu Sep 12, 2024
54ad924
add ci
jasinliu Oct 18, 2024
775e559
Merge branch 'main' of https://github.com/apache/incubator-graphar in…
jasinliu Oct 18, 2024
2b07a69
add vertex info
jasinliu Oct 19, 2024
dd72ad8
change config
jasinliu Oct 19, 2024
5f7ed3c
finish
jasinliu Oct 25, 2024
f60bd49
Merge branch 'main' of https://github.com/apache/incubator-graphar in…
jasinliu Oct 25, 2024
45ab64d
license
jasinliu Oct 25, 2024
3393611
fix license
jasinliu Oct 25, 2024
305cca5
remove conda recipe
jasinliu Oct 25, 2024
cda2487
enbale ci
jasinliu Oct 25, 2024
0dc6ff4
fix typo
jasinliu Oct 25, 2024
8e942be
fix dependency
jasinliu Oct 25, 2024
fb684fc
update ci
jasinliu Oct 25, 2024
5125d9c
add data
jasinliu Oct 25, 2024
9e35d48
fix ci
jasinliu Oct 25, 2024
63e77ee
fix cmake
jasinliu Oct 25, 2024
3b7758a
add arrow in cmake
jasinliu Oct 25, 2024
4d72237
add dependency
jasinliu Oct 25, 2024
9fc7353
fix review
jasinliu Oct 29, 2024
2bee832
Merge branch 'apache:main' into graphar-cli
jasinliu Oct 29, 2024
77bc97c
fix ci
jasinliu Oct 29, 2024
56aa77b
fix ci
jasinliu Oct 29, 2024
955d609
fix ci
jasinliu Oct 29, 2024
726ea84
fix ci
jasinliu Oct 29, 2024
6c39258
Merge branch 'apache:main' into graphar-cli
jasinliu Oct 29, 2024
f0fe5e9
Update cli.yml
jasinliu Oct 29, 2024
18ba462
Update cli.yml
jasinliu Oct 30, 2024
4af9117
fix config type
jasinliu Oct 30, 2024
7b81e42
fix ci with new testing
jasinliu Oct 31, 2024
6ddac61
use enum
jasinliu Oct 31, 2024
9f3258b
use enum
jasinliu Oct 31, 2024
2aa64ad
pin pydantic version
jasinliu Oct 31, 2024
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
116 changes: 116 additions & 0 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

name: GraphAr CLI CI

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
paths:
- 'cpp/**'
- 'cli/**'
- '.github/workflows/ci.yml'
- '.github/workflows/cli.yml'
pull_request:
branches:
- main
paths:
- 'cpp/**'
- 'cli/**'
- '.github/workflows/ci.yml'
- '.github/workflows/cli.yml'
concurrency:
group: ${{ github.repository }}-${{ github.event.number || github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
ubuntu:
name: Ubuntu 22.04 CLI
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.title, 'WIP') && !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Install dependencies
run: |

# install the latest arrow deb to test arrow
wget -c https://apache.jfrog.io/artifactory/arrow/"$(lsb_release --id --short | tr 'A-Z' 'a-z')"/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb \
-P /tmp/
sudo apt-get install -y /tmp/apache-arrow-apt-source-latest-"$(lsb_release --codename --short)".deb
sudo apt-get update -y
sudo apt install -y libarrow-dev \
libarrow-dataset-dev \
libarrow-acero-dev \
libparquet-dev
sudo apt-get install -y ccache libcurl4-openssl-dev

- name: Install GraphAr CLI and Run Tests
working-directory: "cli"
run: |
pip install ./ -v
graphar --help
graphar check -p ../testing/neo4j/MovieGraph.graph.yml
graphar show -p ../testing/neo4j/MovieGraph.graph.yml -v Person
graphar show -p ../testing/neo4j/MovieGraph.graph.yml -es Person -e ACTED_IN -ed Movie
graphar import -c import.mini.yml
# TODO: Add unit tests


- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}

# macos:
# name: ${{ matrix.architecture }} macOS ${{ matrix.macos-version }} CLI
# runs-on: macos-${{ matrix.macos-version }}
# if: ${{ !contains(github.event.pull_request.title, 'WIP') && github.event.pull_request.draft == false }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - architecture: AMD64
# macos-version: "12"
# - architecture: ARM64
# macos-version: "14"
# steps:
# - uses: actions/checkout@v3
# with:
# submodules: true

# - name: Install dependencies
# run: |
# brew bundle --file=cpp/Brewfile


# - name: Build GraphAr And Run Tests
# working-directory: "cli"
# run: |
# pip install ./
# graphar --help
# graphar check -p ../testing/neo4j/MovieGraph.graph.yml
# graphar show -p ../testing/neo4j/MovieGraph.graph.yml -v Person
# graphar show -p ../testing/neo4j/MovieGraph.graph.yml -es Person -e ACTED_IN -ed Movie
# graphar import -c import.full.yml
Copy link
Contributor

@Thespica Thespica Oct 30, 2024

Choose a reason for hiding this comment

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

We can disable the job with if: false, which is considered better to me, rather than ignore the code.

similar to example in this doc:

image

Ps. there should also be a note to explain with why we skip this job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion! Thanks very much!


# TODO: Add unit tests
33 changes: 33 additions & 0 deletions cli/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

BasedOnStyle: Google
DerivePointerAlignment: false
PointerAlignment: Left
Cpp11BracedListStyle: true
IndentCaseLabels: false
AllowShortBlocksOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
Standard: 'Cpp11'
SpaceAfterCStyleCast: true
AlignAfterOpenBracket: Align
SortIncludes: true
IncludeBlocks: Preserve
ForEachMacros:
- BOOST_FOREACH

144 changes: 144 additions & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Using https://github.com/github/gitignore/blob/master/Python.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
docs/_generate/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

_skbuild/
.pyodide-xbuildenv/
60 changes: 60 additions & 0 deletions cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

# Require CMake 3.15+ (matching scikit-build-core) Use new versions of all
# policies up to CMake 3.27
cmake_minimum_required(VERSION 3.15)

# Scikit-build-core sets these values for you, or you can just hard-code the
# name and version.
project(
${SKBUILD_PROJECT_NAME}
VERSION ${SKBUILD_PROJECT_VERSION}
LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../cpp ${CMAKE_BINARY_DIR}/graphar)

# Find the module development requirements (requires FindPython from 3.17 or
# scikit-build-core's built-in backport)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)
find_package(Arrow REQUIRED)
find_package(ArrowDataset REQUIRED)
find_package(ArrowAcero REQUIRED)
find_package(Parquet REQUIRED)

# Add a library using FindPython's tooling (pybind11 also provides a helper like
# this)
python_add_library(_core MODULE src/main.cc WITH_SOABI)

target_link_libraries(_core PRIVATE pybind11::headers graphar Arrow::arrow_shared
Parquet::parquet_shared
ArrowDataset::arrow_dataset_shared
ArrowAcero::arrow_acero_shared
)
target_include_directories(_core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_include_directories(_core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../cpp/src)
target_include_directories(_core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../cpp/thirdparty)

# This is passing in the version as a define just as an example
target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION})

# The install directory is the output (wheel) directory
set_target_properties(_core PROPERTIES INSTALL_RPATH "$ORIGIN")
install(TARGETS graphar DESTINATION graphar_cli)
install(TARGETS _core DESTINATION graphar_cli)
Loading
Loading