batchwizard 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {batchwizard-0.1.0 → batchwizard-0.2.0}/PKG-INFO +38 -4
- {batchwizard-0.1.0 → batchwizard-0.2.0}/README.md +37 -3
- {batchwizard-0.1.0 → batchwizard-0.2.0}/pyproject.toml +1 -1
- {batchwizard-0.1.0 → batchwizard-0.2.0}/src/batchwizard/cli.py +7 -6
- {batchwizard-0.1.0 → batchwizard-0.2.0}/src/batchwizard/processor.py +12 -4
- {batchwizard-0.1.0 → batchwizard-0.2.0}/src/batchwizard/ui.py +11 -3
- {batchwizard-0.1.0 → batchwizard-0.2.0}/LICENSE +0 -0
- {batchwizard-0.1.0 → batchwizard-0.2.0}/src/batchwizard/__init__.py +0 -0
- {batchwizard-0.1.0 → batchwizard-0.2.0}/src/batchwizard/config.py +0 -0
- {batchwizard-0.1.0 → batchwizard-0.2.0}/src/batchwizard/models.py +0 -0
- {batchwizard-0.1.0 → batchwizard-0.2.0}/src/batchwizard/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: batchwizard
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: BatchWizard: Manage OpenAI batch processing jobs with ease
|
|
5
5
|
Home-page: https://github.com/cmakafui/batchwizard
|
|
6
6
|
License: MIT
|
|
@@ -62,10 +62,43 @@ BatchWizard provides a command-line interface (CLI) for managing batch jobs. Her
|
|
|
62
62
|
|
|
63
63
|
### Process Batch Jobs
|
|
64
64
|
|
|
65
|
-
To process
|
|
65
|
+
To process input files or directories:
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
batchwizard process <
|
|
68
|
+
batchwizard process <input_paths>... [--output-directory OUTPUT_DIR] [--max-concurrent-jobs NUM] [--check-interval SECONDS]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
You can provide multiple input paths, which can be individual JSONL files or directories containing JSONL files.
|
|
72
|
+
|
|
73
|
+
#### Example with Sample Input
|
|
74
|
+
|
|
75
|
+
Let's say you have a file named `batchinput.jsonl` with the following content:
|
|
76
|
+
|
|
77
|
+
```jsonl
|
|
78
|
+
{"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4o-mini", "messages": [{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Hello world!"}],"max_tokens": 1000}}
|
|
79
|
+
{"custom_id": "request-2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4o-mini", "messages": [{"role": "system", "content": "You are an unhelpful assistant."},{"role": "user", "content": "Hello world!"}],"max_tokens": 1000}}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
To process this file using BatchWizard:
|
|
83
|
+
|
|
84
|
+
1. First, ensure your OpenAI API key is set:
|
|
85
|
+
```bash
|
|
86
|
+
batchwizard configure --set-key YOUR_API_KEY
|
|
87
|
+
```
|
|
88
|
+
2. Then, run the process command:
|
|
89
|
+
```bash
|
|
90
|
+
batchwizard process /path/to/batchinput.jsonl --output-directory /path/to/output
|
|
91
|
+
```
|
|
92
|
+
This command will:
|
|
93
|
+
- Upload the `batchinput.jsonl` file to OpenAI
|
|
94
|
+
- Create a batch job
|
|
95
|
+
- Monitor the job status
|
|
96
|
+
- Download the results to the specified output directory when complete
|
|
97
|
+
|
|
98
|
+
You can also process multiple files or directories:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
batchwizard process /path/to/file1.jsonl /path/to/directory_with_jsonl_files /path/to/file2.jsonl
|
|
69
102
|
```
|
|
70
103
|
|
|
71
104
|
### List Recent Jobs
|
|
@@ -122,7 +155,7 @@ batchwizard configure --reset
|
|
|
122
155
|
|
|
123
156
|
BatchWizard supports the following commands:
|
|
124
157
|
|
|
125
|
-
- `process`: Process batch jobs from input files
|
|
158
|
+
- `process`: Process batch jobs from input files or directories.
|
|
126
159
|
- `configure`: Manage BatchWizard configuration.
|
|
127
160
|
- `list-jobs`: List recent batch jobs.
|
|
128
161
|
- `cancel`: Cancel a specific batch job.
|
|
@@ -136,6 +169,7 @@ batchwizard <command> --help
|
|
|
136
169
|
|
|
137
170
|
## Features
|
|
138
171
|
|
|
172
|
+
- **Flexible Input**: Process individual JSONL files or entire directories containing JSONL files.
|
|
139
173
|
- **Asynchronous Processing**: Efficiently handle multiple batch jobs concurrently.
|
|
140
174
|
- **Rich UI**: Display progress and job status using a rich, interactive interface.
|
|
141
175
|
- **Flexible Configuration**: Easily manage API keys and other settings.
|
|
@@ -36,10 +36,43 @@ BatchWizard provides a command-line interface (CLI) for managing batch jobs. Her
|
|
|
36
36
|
|
|
37
37
|
### Process Batch Jobs
|
|
38
38
|
|
|
39
|
-
To process
|
|
39
|
+
To process input files or directories:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
batchwizard process <
|
|
42
|
+
batchwizard process <input_paths>... [--output-directory OUTPUT_DIR] [--max-concurrent-jobs NUM] [--check-interval SECONDS]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
You can provide multiple input paths, which can be individual JSONL files or directories containing JSONL files.
|
|
46
|
+
|
|
47
|
+
#### Example with Sample Input
|
|
48
|
+
|
|
49
|
+
Let's say you have a file named `batchinput.jsonl` with the following content:
|
|
50
|
+
|
|
51
|
+
```jsonl
|
|
52
|
+
{"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4o-mini", "messages": [{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Hello world!"}],"max_tokens": 1000}}
|
|
53
|
+
{"custom_id": "request-2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4o-mini", "messages": [{"role": "system", "content": "You are an unhelpful assistant."},{"role": "user", "content": "Hello world!"}],"max_tokens": 1000}}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
To process this file using BatchWizard:
|
|
57
|
+
|
|
58
|
+
1. First, ensure your OpenAI API key is set:
|
|
59
|
+
```bash
|
|
60
|
+
batchwizard configure --set-key YOUR_API_KEY
|
|
61
|
+
```
|
|
62
|
+
2. Then, run the process command:
|
|
63
|
+
```bash
|
|
64
|
+
batchwizard process /path/to/batchinput.jsonl --output-directory /path/to/output
|
|
65
|
+
```
|
|
66
|
+
This command will:
|
|
67
|
+
- Upload the `batchinput.jsonl` file to OpenAI
|
|
68
|
+
- Create a batch job
|
|
69
|
+
- Monitor the job status
|
|
70
|
+
- Download the results to the specified output directory when complete
|
|
71
|
+
|
|
72
|
+
You can also process multiple files or directories:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
batchwizard process /path/to/file1.jsonl /path/to/directory_with_jsonl_files /path/to/file2.jsonl
|
|
43
76
|
```
|
|
44
77
|
|
|
45
78
|
### List Recent Jobs
|
|
@@ -96,7 +129,7 @@ batchwizard configure --reset
|
|
|
96
129
|
|
|
97
130
|
BatchWizard supports the following commands:
|
|
98
131
|
|
|
99
|
-
- `process`: Process batch jobs from input files
|
|
132
|
+
- `process`: Process batch jobs from input files or directories.
|
|
100
133
|
- `configure`: Manage BatchWizard configuration.
|
|
101
134
|
- `list-jobs`: List recent batch jobs.
|
|
102
135
|
- `cancel`: Cancel a specific batch job.
|
|
@@ -110,6 +143,7 @@ batchwizard <command> --help
|
|
|
110
143
|
|
|
111
144
|
## Features
|
|
112
145
|
|
|
146
|
+
- **Flexible Input**: Process individual JSONL files or entire directories containing JSONL files.
|
|
113
147
|
- **Asynchronous Processing**: Efficiently handle multiple batch jobs concurrently.
|
|
114
148
|
- **Rich UI**: Display progress and job status using a rich, interactive interface.
|
|
115
149
|
- **Flexible Configuration**: Easily manage API keys and other settings.
|
|
@@ -20,8 +20,8 @@ logger = setup_logger(console)
|
|
|
20
20
|
|
|
21
21
|
@app.command()
|
|
22
22
|
def process(
|
|
23
|
-
|
|
24
|
-
..., help="
|
|
23
|
+
input_paths: list[Path] = typer.Argument(
|
|
24
|
+
..., help="Paths to input files or directories for processing"
|
|
25
25
|
),
|
|
26
26
|
output_directory: Optional[Path] = typer.Option(
|
|
27
27
|
None, help="Directory to store output files"
|
|
@@ -33,15 +33,15 @@ def process(
|
|
|
33
33
|
5, help="Initial interval (in seconds) between job status checks"
|
|
34
34
|
),
|
|
35
35
|
):
|
|
36
|
-
"""Process batch jobs from input files
|
|
36
|
+
"""Process batch jobs from input files or directories."""
|
|
37
37
|
if not output_directory:
|
|
38
|
-
output_directory =
|
|
38
|
+
output_directory = Path.cwd() / "results"
|
|
39
39
|
output_directory.mkdir(parents=True, exist_ok=True)
|
|
40
40
|
|
|
41
41
|
api_key = get_api_key()
|
|
42
42
|
if not api_key:
|
|
43
43
|
logger.error(
|
|
44
|
-
"API key not set. Please set it using '
|
|
44
|
+
"API key not set. Please set it using 'openaibatch configure --set-key YOUR_API_KEY'"
|
|
45
45
|
)
|
|
46
46
|
raise typer.Exit(code=1)
|
|
47
47
|
|
|
@@ -54,13 +54,14 @@ def process(
|
|
|
54
54
|
|
|
55
55
|
async def run_and_close():
|
|
56
56
|
try:
|
|
57
|
-
await ui.run_processing(processor,
|
|
57
|
+
await ui.run_processing(processor, input_paths, output_directory)
|
|
58
58
|
finally:
|
|
59
59
|
await processor.close()
|
|
60
60
|
|
|
61
61
|
asyncio.run(run_and_close())
|
|
62
62
|
|
|
63
63
|
|
|
64
|
+
|
|
64
65
|
@app.command()
|
|
65
66
|
def configure(
|
|
66
67
|
set_key: Optional[str] = typer.Option(
|
|
@@ -118,12 +118,20 @@ class BatchProcessor:
|
|
|
118
118
|
check_interval * 1.5, 60
|
|
119
119
|
) # Implement exponential backoff
|
|
120
120
|
|
|
121
|
-
async def
|
|
122
|
-
self,
|
|
121
|
+
async def process_inputs(
|
|
122
|
+
self, input_paths: List[Path], output_dir: Path
|
|
123
123
|
) -> List[BatchJobResult]:
|
|
124
|
-
input_files =
|
|
124
|
+
input_files = []
|
|
125
|
+
for path in input_paths:
|
|
126
|
+
if path.is_dir():
|
|
127
|
+
input_files.extend(path.glob("*.jsonl"))
|
|
128
|
+
elif path.suffix.lower() == ".jsonl":
|
|
129
|
+
input_files.append(path)
|
|
130
|
+
else:
|
|
131
|
+
logger.warning(f"Skipping non-JSONL file: {path}")
|
|
132
|
+
|
|
125
133
|
if not input_files:
|
|
126
|
-
logger.warning(
|
|
134
|
+
logger.warning("No input files found in the provided paths")
|
|
127
135
|
return []
|
|
128
136
|
|
|
129
137
|
semaphore = asyncio.Semaphore(self.settings.max_concurrent_jobs)
|
|
@@ -128,7 +128,7 @@ class BatchWizardUI:
|
|
|
128
128
|
layout["body"]["sidebar"]["logs"].update(log_panel)
|
|
129
129
|
|
|
130
130
|
async def run_processing(
|
|
131
|
-
self, processor: BatchProcessor,
|
|
131
|
+
self, processor: BatchProcessor, input_paths: List[Path], output_dir: Path
|
|
132
132
|
):
|
|
133
133
|
layout = self.create_layout()
|
|
134
134
|
overall_progress, job_progress = self.create_progress_bars()
|
|
@@ -150,9 +150,17 @@ class BatchWizardUI:
|
|
|
150
150
|
with Live(layout, console=self.console, screen=True, refresh_per_second=4):
|
|
151
151
|
await update_ui()
|
|
152
152
|
|
|
153
|
-
input_files =
|
|
153
|
+
input_files = []
|
|
154
|
+
for path in input_paths:
|
|
155
|
+
if path.is_dir():
|
|
156
|
+
input_files.extend(path.glob("*.jsonl"))
|
|
157
|
+
elif path.suffix.lower() == ".jsonl":
|
|
158
|
+
input_files.append(path)
|
|
159
|
+
else:
|
|
160
|
+
self.add_log(f"Skipping non-JSONL file: {path}")
|
|
161
|
+
|
|
154
162
|
if not input_files:
|
|
155
|
-
self.add_log(
|
|
163
|
+
self.add_log("No input files found in the provided paths")
|
|
156
164
|
await update_ui()
|
|
157
165
|
return
|
|
158
166
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|