10000 Update submission instructions, and fix predict.py · github/CodeSearchNet@5d137bc · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 11, 2023. It is now read-only.

Commit 5d137bc

Browse files
committed
Update submission instructions, and fix predict.py
- Move hint for users following quickstart to top - Get rid of example script for submitting custom model predictions, it wouldn't have worked well anyway. We should make a separate simple script that does this. - More helpful text for finding the submit button in the UI Use wandb internal API to avoid resuming, which breaks run duration and config.
1 parent e81205b commit 5d137bc

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

BENCHMARK.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ There are a few requirements for submitting a model to the benchmark.
1313

1414
### Submission format
1515

16+
*To submit from our baseline model, skip to the [training the baseline model](#training-the-baseline-model-optional) section below.*
17+
1618
A valid submission to the CodeSeachNet Challenge requires a file named **model_predictions.csv** with the following fields: `query`, `language`, `identifier`, and `url`:
1719

1820
* `query`: the textual representation of the query, e.g. "int to string" .
@@ -24,8 +26,6 @@ For further background and instructions on the submission process, see [the root
2426

2527
The row order corresponds to the result ranking in the search task. For example, if in row 5 there is an entry for the Python query "read properties file", and in row 60 another result for the Python query "read properties file", then the URL in row 5 is considered to be ranked higher than the URL in row 60 for that query and language.
2628

27-
The script we used to create the baseline submission is [src/predict.py](src/predict.py). You are not required to use this script to produce your submission file; we only provide it for reference.
28-
2929
Here is an example:
3030

3131
| query | language | identifier | url |
@@ -49,13 +49,7 @@ You can submit your results to the benchmark as follows:
4949
2. Generate your own file of model predictions following the format above and name it \`model_predictions.csv\`.
5050
3. Upload a run to wandb with this \`model_predictions.csv\` file attached.
5151

52-
Our example script [src/predict.py](src/predict.py) takes care of steps 2 and 3 for a model training run that has already been logged to W&B, given the corresponding W&B run id, which you can find on the /overview page in the browser or by clicking the 'info' icon on a given run.
53-
54-
Here is a short example script that will create a run in W&B and perform the upload (step 3) for a local file of predictions:
55-
```python
56-
import wandb
57-
wandb.init(project="codesearchnet")
58-
wandb.save('model_predictions.csv')
52+
Our example script [src/predict.py](src/predict.py) takes care of steps 2 and 3 for a model whose training run has been logged to W&B, given the corresponding W&B run id, which you can find on the /overview page in the browser or by clicking the 'info' icon on a given run.
5953
```
6054
6155
### Publishing your submission
@@ -65,7 +59,7 @@ You've now generated all the content required to submit a run to the CodeSearchN
6559
You can submit your runs by visiting the run page and clicking on the overview tab:
6660
![](https://github.com/wandb/core/blob/master/frontends/app/src/assets/run-page-benchmark.png?raw=true)
6761
68-
or by selecting a run from the runs table:
62+
or by visiting the project page and selecting a run from the runs table:
6963
![](https://app.wandb.ai/static/media/submit_benchmark_run.e286da0d.png)
7064
7165
### Result evaluation
@@ -75,6 +69,6 @@ Once you upload your \`model_predictions.csv\` file, W&B will compute the normal
7569
7670
### Training the baseline model (optional)
7771
78-
Replicating our results for the CodeSearchNet baseline is optional, as we encourage the community to create their own models and methods for ranking search results. To replicate our baseline submission, you can start with the instructions in the [CodeSearchNet GitHub repository](https://github.com/github/CodeSearchNet). This baseline model uses [src/predict.py](src/predict.py) to generate the submission file.
72+
Replicating our results for the CodeSearchNet baseline is optional, as we encourage the community to create their own models and methods for ranking search results. To replicate our baseline submission, you can start with the "Quickstart" instructions in the [CodeSearchNet GitHub repository](https://github.com/github/CodeSearchNet). This baseline model uses [src/predict.py](src/predict.py) to generate the submission file.
7973
8074
Your run will be logged to W&B, within a project that will be automatically linked to this benchmark.

src/predict.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import pandas as pd
5959
from tqdm import tqdm
6060
import wandb
61+
from wandb.apis import InternalApi
6162

6263
from dataextraction.python.parse_python_data import tokenize_docstring_from_string
6364
import model_restore_helper
@@ -93,7 +94,11 @@ def query_model(query, model, indices, language, topk=100):
9394
print("ERROR: Problem querying W&B for wandb_run_id: %s" % args_wandb_run_id, file=sys.stderr)
9495
sys.exit(1)
9596

96-
model_file = [f for f in run.files() if f.name.endswith('gz')][0].download(replace=True)
97+
gz_run_files = [f for f in run.files() if f.name.endswith('gz')]
98+
if not gz_run_files:
99+
print("ERROR: Run contains no model-like files")
100+
sys.exit(1)
101+
model_file = gz_run_files[0].download(replace=True)
97102
local_model_path = model_file.name
98103
run_id = args_wandb_run_id.split('/')[-1]
99104

@@ -126,5 +131,8 @@ def query_model(query, model, indices, language, topk=100):
126131

127132
if run_id:
128133
# upload model predictions CSV file to W&B
129-
wandb.init(id=run_id, resume="must")
130-
wandb.save(predictions_csv)
134+
135+
# we checked that there are three path components above
136+
entity, project, name = args_wandb_run_id.split('/')
137+
internal_api = InternalApi()
138+
internal_api.push([predictions_csv], run=name, entity=entity, project=project)

0 commit comments

Comments
 (0)
0