Skip to content

Commit 1a9f3f9

Browse files
author
Justin Merrell
committed
fix: predictor -> run & cleanup output folder checker
1 parent e6854ab commit 1a9f3f9

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

docs/serverless-worker.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,16 @@ Worker zero can have a modified TTL behavior, to flag a worker as worker zero se
6464
When the TTL of a worker has expired the function `self.seppuku` is called. On exit the following actions are taken:
6565

6666
- RunPod API call to delete the pod
67+
68+
## Local Testing
69+
70+
To test locally, create the file `test_inputs.json` in the root directory that contains the following:
71+
72+
```json
73+
{
74+
"id": "LOCAL-TEST",
75+
"input":{}
76+
}
77+
```
78+
79+
The inputS should match the inputs your model would expect to see from the API.

infer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'''
22
Template for the infer.py file.
3-
Input -> model perameters
3+
Input -> model parameters
44
Output -> list of files
55
'''
66

@@ -11,7 +11,7 @@ class Predictor:
1111
def setup(self):
1212
''' Loads the model. '''
1313

14-
def predict(self, model_inputs):
14+
def run(self, model_inputs):
1515
'''
1616
Predicts the output of the model.
1717
'''

runpod/serverless/modules/inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ def run(self, model_inputs):
2424
'''
2525
Predicts the output of the model.
2626
'''
27-
return self.predictor.predict(model_inputs)
27+
return self.predictor.run(model_inputs)

runpod/serverless/pod_worker.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ def start_worker():
3333
worker_life.work_in_progress = True # Rests when "reset_worker_ttl" is called
3434

3535
try:
36-
output_urls, job_duration_ms = job.run(next_job['id'], next_job['input'])
37-
job.post(worker_life.worker_id, next_job['id'], output_urls, job_duration_ms)
36+
output_urls, job_duration_ms = job.run(
37+
next_job['id'], next_job['input'])
38+
job.post(worker_life.worker_id,
39+
next_job['id'], output_urls, job_duration_ms)
3840
except ValueError as err:
3941
job.error(worker_life.worker_id, next_job['id'], str(err))
4042

4143
# -------------------------------- Job Cleanup ------------------------------- #
4244
shutil.rmtree("input_objects", ignore_errors=True)
4345
shutil.rmtree("output_objects", ignore_errors=True)
44-
os.remove('output.zip')
46+
os.remove('output.zip') if os.path.exists('output.zip') else None
4547

4648
worker_life.reset_worker_ttl()
4749

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = runpod
3-
version = 0.1.5
3+
version = 0.1.6
44
description = Official Python library for RunPod API & SDK.
55
long_description = file: README.md
66
long_description_content_type = text/markdown

0 commit comments

Comments
 (0)