You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hugegraph.apache.org by "ChenZiHong-Gavin (via GitHub)" <gi...@apache.org> on 2024/05/29 07:09:58 UTC
[I] [Question] A question about introducing black for code format [incubator-hugegraph-ai]
ChenZiHong-Gavin opened a new issue, #46:
URL: https://github.com/apache/incubator-hugegraph-ai/issues/46
### Problem Type (问题类型)
configs (配置项 / 文档相关)
### Before submit
- [X] I had searched in the [issues](https://github.com/apache/incubator-hugegraph-ai/issues) and found no similar issues.
### Environment (环境信息)
- Server Version: 1.x.x
- Toolchain Version: 1.x.x
- Data Size: xx vertices, xx edges <!-- (like 1000W 点,9000W 边) -->>
### Your Question (问题描述)
I am thinking about introducing BLACK for code check but still confused about the process.
I also noticed that there's a **style script** already using BLACK, refer: https://github.com/apache/incubator-hugegraph-ai/blob/main/style/code_format_and_analysis.sh
This script is used in the pylint.yml workflow, but only the pylint functionality is enabled. Should I create a new workflow for using BLACK, following the structure of pylint.yml, or should I modify pylint.yml to make it capable of performing code formatting tasks as well?
### Vertex/Edge example (问题点 / 边数据举例)
_No response_
### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@hugegraph.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Question] A question about introducing black for code format [incubator-hugegraph-ai]
Posted by "ChenZiHong-Gavin (via GitHub)" <gi...@apache.org>.
ChenZiHong-Gavin commented on issue #46:
URL: https://github.com/apache/incubator-hugegraph-ai/issues/46#issuecomment-2136934208
Also, BLACK provides GitHub Actions integration(https://black.readthedocs.io/en/stable/integrations/github_actions.html), and i believe it's better because its flexibility
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Question] A question about introducing black for code format [incubator-hugegraph-ai]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #46:
URL: https://github.com/apache/incubator-hugegraph-ai/issues/46#issuecomment-2154364039
<!-- Answer -->
@ChenZiHong-Gavin, integrating BLACK into your CI workflow while adhering to Apache's action rules can be challenging. Here is an example of how BLACK is integrated within the constraints of Apache's action rules:
```yaml
name: "Black Code Formatter"
on:
push:
branches:
- 'release-*'
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@3702ba224ecffbcec30af640c149f231d90aebdb
with:
options: "--check --diff --line-length 100"
src: "hugegraph-llm/src hugegraph-python-client/src"
```
Additionally, the `incubator-hugegraph-ai` repository includes a script for running BLACK and PYLINT checks:
```sh
#! /bin/bash
BLACK=false
PYLINT=false
ROOT_DIR=$(pwd)
echo ${ROOT_DIR}
# Parse command line arguments
while getopts ":bp" opt; do
case ${opt} in
b )
BLACK=true
;;
p )
PYLINT=true
;;
\? )
echo "Usage: cmd [-b] [-p]"
;;
esac
done
# If no arguments were provided, run both BLACK and PYLINT
if [ "$BLACK" = false ] && [ "$PYLINT" = false ]; then
BLACK=true
PYLINT=true
fi
# Run BLACK if -b is specified
if [ "$BLACK" = true ] ; then
echo "[black] Start to check code style and auto format"
black --line-length=100 ${ROOT_DIR}
fi
# Run PYLINT if -p is specified
if [ "$PYLINT" = true ] ; then
echo "[pylint] Start code analysis and check,
we need to manually fix all the warnings mentioned below before commit! "
export PYTHONPATH=${ROOT_DIR}/hugegraph-llm/src:${ROOT_DIR}/hugegraph-python-client/src
pylint --rcfile=${ROOT_DIR}/style/pylint.conf ${ROOT_DIR}/hugegraph-llm
pylint --rcfile=${ROOT_DIR}/style/pylint.conf --disable C0103 ${ROOT_DIR}/hugegraph-python-client
fi
```
This script allows for flexible integration of BLACK and PYLINT checks, either individually or together, based on command-line arguments <sup>[[1]](https://github.com/apache/incubator-hugegraph-ai/blob/main/.github/workflows/black.yml)</sup><sup>[[2]](https://github.com/apache/incubator-hugegraph-ai/blob/main/style/code_format_and_analysis.sh)</sup>.
If you need further assistance or have more questions, feel free to ask. Happy coding!
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Question] A question about introducing black for code format [incubator-hugegraph-ai]
Posted by "ChenZiHong-Gavin (via GitHub)" <gi...@apache.org>.
ChenZiHong-Gavin commented on issue #46:
URL: https://github.com/apache/incubator-hugegraph-ai/issues/46#issuecomment-2136706484
> @ChenZiHong-Gavin 你好! 我是Dosu,一个可以帮助你解决错误、回答问题并成为贡献者的机器人。我将在等待人类维护者的过程中协助你。
>
> You should modify `pylint.yml` to include code formatting tasks as well. The provided script `style/code_format_and_analysis.sh` already supports running both BLACK and PYLINT together or separately based on the provided command-line arguments. This indicates that the workflow can be combined.
>
> Here is an example of how you might modify `pylint.yml` to include BLACK:
>
> ```yaml
> name: "Lint and Format"
>
> on:
> push:
> branches:
> - 'release-*'
> pull_request:
>
> jobs:
> build:
> runs-on: ubuntu-latest
> strategy:
> matrix:
> python-version: ["3.9", "3.10"]
> steps:
> - uses: actions/checkout@v4
> - name: Set up Python ${{ matrix.python-version }}
> uses: actions/setup-python@v3
> with:
> python-version: ${{ matrix.python-version }}
> - name: Install dependencies
> run: |
> python -m pip install --upgrade pip
> pip install black pylint pytest
> pip install -r ./hugegraph-llm/requirements.txt
> pip install -r ./hugegraph-llm/llm_api/requirements.txt
> pip install -r ./hugegraph-python-client/requirements.txt
> - name: Run code format and analysis
> run: |
> chmod +x style/code_format_and_analysis.sh
> ./style/code_format_and_analysis.sh -b -p
> ```
>
> This workflow will run both BLACK and PYLINT as specified in the `style/code_format_and_analysis.sh` script [[1]](https://github.com/apache/incubator-hugegraph-ai/blob/main/style/code_format_and_analysis.sh?rgh-link-date=2024-05-29T07%3A14%3A29Z)[[2]](https://github.com/apache/incubator-hugegraph-ai/blob/main/.github/workflows/pylint.yml?rgh-link-date=2024-05-29T07%3A14%3A29Z).
>
> #### Details
> **About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research.
>
> Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
>
> _To continue the conversation, mention @dosu._
it makes sense
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Question] A question about introducing black for code format [incubator-hugegraph-ai]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #46:
URL: https://github.com/apache/incubator-hugegraph-ai/issues/46#issuecomment-2136707326
<!-- Answer -->
Great! It sounds like you're on the right track. If you need any further assistance or have more questions, feel free to ask. Happy coding!
<!-- Dosu Comment Footer -->
<details>
<summary>
#### Details
</summary>
**About Dosu**
This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
</details>
*To continue the conversation, mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Question] A question about introducing black for code format [incubator-hugegraph-ai]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on issue #46:
URL: https://github.com/apache/incubator-hugegraph-ai/issues/46#issuecomment-2154310768
@dosu we used the action(black CI) but it was banned by Apache's action rule, can you find examples of other Apache projects(in GitHub) using black as a code CI check or how to correctly reference black?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [I] [Question] A question about introducing black for code format [incubator-hugegraph-ai]
Posted by "ChenZiHong-Gavin (via GitHub)" <gi...@apache.org>.
ChenZiHong-Gavin closed issue #46: [Question] A question about introducing black for code format
URL: https://github.com/apache/incubator-hugegraph-ai/issues/46
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Question] A question about introducing black for code format [incubator-hugegraph-ai]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #46:
URL: https://github.com/apache/incubator-hugegraph-ai/issues/46#issuecomment-2136699890
<!-- Greeting -->
@ChenZiHong-Gavin 你好! 我是Dosu,一个可以帮助你解决错误、回答问题并成为贡献者的机器人。我将在等待人类维护者的过程中协助你。
<!-- Answer -->
You should modify `pylint.yml` to include code formatting tasks as well. The provided script `style/code_format_and_analysis.sh` already supports running both BLACK and PYLINT together or separately based on the provided command-line arguments. This indicates that the workflow can be combined.
Here is an example of how you might modify `pylint.yml` to include BLACK:
```yaml
name: "Lint and Format"
on:
push:
branches:
- 'release-*'
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black pylint pytest
pip install -r ./hugegraph-llm/requirements.txt
pip install -r ./hugegraph-llm/llm_api/requirements.txt
pip install -r ./hugegraph-python-client/requirements.txt
- name: Run code format and analysis
run: |
chmod +x style/code_format_and_analysis.sh
./style/code_format_and_analysis.sh -b -p
```
This workflow will run both BLACK and PYLINT as specified in the `style/code_format_and_analysis.sh` script <sup>[[1]](https://github.com/apache/incubator-hugegraph-ai/blob/main/style/code_format_and_analysis.sh)</sup><sup>[[2]](https://github.com/apache/incubator-hugegraph-ai/blob/main/.github/workflows/pylint.yml)</sup>.
<!-- Dosu Comment Footer -->
<details open>
<summary>
#### Details
</summary>
**About Dosu**
This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
</details>
*To continue the conversation, mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org