Skip to content

Commit

Permalink
fix: try to fix hf space
Browse files Browse the repository at this point in the history
  • Loading branch information
k4black committed Jul 12, 2023
1 parent c63bc0f commit a784b3f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ jobs:
git commit --allow-empty -m "Auto files update [${{ github.ref_name }}]"
ls -lah
git push https://k4black:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/k4black/codebleu main
36 changes: 18 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,21 @@ jobs:
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)

sync-to-hf-hub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download hf repo
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git clone https://k4black:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/k4black/codebleu hf_evaluate_codebleu
git checkout main
- name: Update files and push
run: |
cp -r evaluate_app/* hf_evaluate_codebleu
cd hf_evaluate_codebleu
git add .
git commit --allow-empty -m "Auto files update [${{ github.ref_name }}]"
ls -lah
git push https://k4black:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/k4black/codebleu main
# sync-to-hf-hub:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Download hf repo
# run: |
# git config --global user.name 'github-actions'
# git config --global user.email '[email protected]'
# git clone https://k4black:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/k4black/codebleu hf_evaluate_codebleu
# git checkout main
# - name: Update files and push
# run: |
# cp -r evaluate_app/* hf_evaluate_codebleu
# cd hf_evaluate_codebleu
# git add .
# git commit --allow-empty -m "Auto files update [${{ github.ref_name }}]"
# ls -lah
# git push https://k4black:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/k4black/codebleu main
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ print(result)
where calc_codebleu takes the following arguments:
- `refarences` (`list[str]` or `list[list[str]]`): reference code
- `predictions` (`list[str]`) predicted code
- `lang` (`str`): code language, see `codebleu.AVAILABLE_LANGS` for available languages (python, c_sharp, java at the moment)
- `weights` (tuple[float,float,float,float]): weights of the `ngram_match`, `weighted_ngram_match`, `syntax_match`, and `dataflow_match` respectively, defaults to `(0.25, 0.25, 0.25, 0.25)`
- `lang` (`str`): code language, see `codebleu.AVAILABLE_LANGS` for available languages (python, c_sharp c, cpp, javascript, java, php at the moment)
- `weights` (`tuple[float,float,float,float]`): weights of the `ngram_match`, `weighted_ngram_match`, `syntax_match`, and `dataflow_match` respectively, defaults to `(0.25, 0.25, 0.25, 0.25)`
- `tokenizer` (`callable`): to split code string to tokens, defaults to `s.split()`

and outputs the `dict[str, float]` with following fields:
Expand All @@ -62,6 +62,9 @@ Alternatively, you can use `k4black/codebleu` from HuggingFace Spaces:
import evaluate
metric = evaluate.load("dvitel/codebleu")

prediction = "def add ( a , b ) :\n return a + b"
reference = "def sum ( first , second ) :\n return second + first"

result = metric.compute([reference], [prediction], lang="python", weights=(0.25, 0.25, 0.25, 0.25))
```

Expand Down
4 changes: 2 additions & 2 deletions evaluate_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ The metric has shown higher correlation with human evaluation than `BLEU` and `a

- `refarences` (`list[str]` or `list[list[str]]`): reference code
- `predictions` (`list[str]`) predicted code
- `lang` (`str`): code language, see `codebleu.AVAILABLE_LANGS` for available languages (python, c_sharp, java at the moment)
- `weights` (tuple[float,float,float,float]): weights of the `ngram_match`, `weighted_ngram_match`, `syntax_match`, and `dataflow_match` respectively, defaults to `(0.25, 0.25, 0.25, 0.25)`
- `lang` (`str`): code language, see `codebleu.AVAILABLE_LANGS` for available languages (python, c_sharp c, cpp, javascript, java, php at the moment)
- `weights` (`tuple[float,float,float,float]`): weights of the `ngram_match`, `weighted_ngram_match`, `syntax_match`, and `dataflow_match` respectively, defaults to `(0.25, 0.25, 0.25, 0.25)`
- `tokenizer` (`callable`): to split code string to tokens, defaults to `s.split()`


Expand Down
2 changes: 1 addition & 1 deletion evaluate_app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
git+https://github.com/huggingface/evaluate@main
codebleu
codebleu>=0.1.8,<1.0.0

0 comments on commit a784b3f

Please sign in to comment.