Skip to content

Commit c983f2e

Browse files
committed
run lints
1 parent cab32b9 commit c983f2e

31 files changed

+2966
-260
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ FROM mcr.microsoft.com/devcontainers/python:3.9
33
ENV PYTHONUNBUFFERED 1
44

55
# Install pre-commit
6-
RUN pip install pre-commit
6+
RUN pip install pre-commit

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
},
66
"features": {
77
"ghcr.io/devcontainers/features/git:1": {},
8+
"ghcr.io/devcontainers/features/node:1": {},
89
"ghcr.io/devcontainers/features/java:1": {
910
"version": "17",
1011
"installMaven": false,
@@ -37,4 +38,4 @@
3738
},
3839
"postCreateCommand": "poetry install",
3940
"remoteUser": "vscode"
40-
}
41+
}

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ install:
3131
format:
3232
poetry run pre-commit run --all-files
3333

34+
# OpenAPI Client Generation
35+
36+
generate-client:
37+
python scripts/generate_api_client.py
3438

3539
# Documentation
3640

examples/tokenize_data.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def tokenize_variable_length(
2525
tokenizer: PreTrainedTokenizerBase,
2626
add_special_tokens: bool = True,
2727
) -> BatchEncoding:
28-
tokenized = tokenizer(
29-
data["text"], add_special_tokens=add_special_tokens, truncation=False
30-
)
28+
tokenized = tokenizer(data["text"], add_special_tokens=add_special_tokens, truncation=False)
3129
return tokenized
3230

3331

@@ -102,10 +100,7 @@ def pack_sequences(
102100
output = {"input_ids": packed_sequences}
103101
if add_labels:
104102
output["labels"] = [
105-
[
106-
LOSS_IGNORE_INDEX if token_id == pad_token_id else token_id
107-
for token_id in example
108-
]
103+
[LOSS_IGNORE_INDEX if token_id == pad_token_id else token_id for token_id in example]
109104
for example in output["input_ids"]
110105
]
111106

@@ -201,18 +196,14 @@ def process_data(args: argparse.Namespace) -> None:
201196

202197

203198
if __name__ == "__main__":
204-
parser = argparse.ArgumentParser(
205-
description="Pretokenize examples for finetuning via Together"
206-
)
199+
parser = argparse.ArgumentParser(description="Pretokenize examples for finetuning via Together")
207200
parser.add_argument(
208201
"--dataset",
209202
type=str,
210203
default="clam004/antihallucination_dataset",
211204
help="Dataset name on the Hugging Face Hub",
212205
)
213-
parser.add_argument(
214-
"--max-seq-length", type=int, default=8192, help="Maximum sequence length"
215-
)
206+
parser.add_argument("--max-seq-length", type=int, default=8192, help="Maximum sequence length")
216207
parser.add_argument(
217208
"--add-labels",
218209
action="store_true",

mypy.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
[mypy]
22
plugins = pydantic.mypy
3+
disallow_untyped_defs = true
4+
5+
[mypy-together.generated.*]
6+
ignore_errors = true
7+
8+
[mypy.tests.*]
9+
ignore_errors = true

scripts/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
openapi-generator-cli.jar
2-
openapi.yaml
2+

scripts/generate_api_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
GENERATOR_JAR = Path(__file__).parent / "openapi-generator-cli.jar"
1414

1515

16-
def run_command(cmd: list[str], check: bool = True) -> subprocess.CompletedProcess:
16+
def run_command(cmd: list[str], check: bool = True) -> subprocess.CompletedProcess[str]:
1717
"""Run a command and optionally check its return code."""
1818
print(f"Running: {' '.join(cmd)}")
1919
return subprocess.run(cmd, check=check, capture_output=True, text=True)
@@ -31,6 +31,9 @@ def main() -> None:
3131
spec_file = Path(__file__).parent / "openapi.yaml"
3232
download_file(OPENAPI_SPEC_URL, spec_file)
3333

34+
# Run formatter on the spec for better merge conflict handling
35+
run_command(["npx", "-y", "prettier", "--write", str(spec_file)])
36+
3437
# Download generator if needed
3538
download_file(GENERATOR_JAR_URL, GENERATOR_JAR)
3639

0 commit comments

Comments
 (0)