How to start a pod using command line runpodctl or python sdk

No description
Solution:
GitHub
GitHub - runpod/runpod-python: 🐍 | Python library for RunPod API an...
🐍 | Python library for RunPod API and serverless worker SDK. - GitHub - runpod/runpod-python: 🐍 | Python library for RunPod API and serverless worker SDK.
Jump to solution
11 Replies
Asad Cognify
Asad CognifyOP6mo ago
It worked after a few minutes Can anyone guide me as to how to start a pod using python sdk?
nerdylive
nerdylive6mo ago
mmm did it work with the runpodctl too? import runpod runpod.api_key = "your_runpod_api_key_found_under_settings" Get all my pods pods = runpod.get_pods() Get a specific pod pod = runpod.get_pod(pod.id) Create a pod pod = runpod.create_pod("test", "runpod/stack", "NVIDIA GeForce RTX 3070") Stop the pod runpod.stop_pod(pod.id) Resume the pod runpod.resume_pod(pod.id) Terminate the pod runpod.terminate_pod(pod.id)
Solution
nerdylive
nerdylive6mo ago
GitHub
GitHub - runpod/runpod-python: 🐍 | Python library for RunPod API an...
🐍 | Python library for RunPod API and serverless worker SDK. - GitHub - runpod/runpod-python: 🐍 | Python library for RunPod API and serverless worker SDK.
Asad Cognify
Asad CognifyOP6mo ago
It does. But not on the first attempt.
nerdylive
nerdylive6mo ago
hmm weird maybe its not in stopped
Asad Cognify
Asad CognifyOP6mo ago
@nerdylive Bro can you help me receive json file on the pod? I am running a flask app on 5000
from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/finetune', methods=['POST'])
def receive_finetune_request():
data = request.get_json()
bot_id = data.get('bot_id')
print(bot_id)
return jsonify({"message": "Received bot_id", "bot_id": bot_id}), 200

if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)
from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route('/finetune', methods=['POST'])
def receive_finetune_request():
data = request.get_json()
bot_id = data.get('bot_id')
print(bot_id)
return jsonify({"message": "Received bot_id", "bot_id": bot_id}), 200

if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)
python app.py
python app.py
It starts the dev server how do send a post request to it with json using curl and postman? I want to use the proxy.runpod.net later but current I am able to accomplish it with curl on localhost
curl -X 'POST' http://127.0.0.1:5000/finetune -H 'Content-Type: application/json' -d '{"bot_id": "112547"}'
{"bot_id":"112547","message":"Received bot_id"}
curl -X 'POST' http://127.0.0.1:5000/finetune -H 'Content-Type: application/json' -d '{"bot_id": "112547"}'
{"bot_id":"112547","message":"Received bot_id"}
As well as on the flask screen
112547
127.0.0.1 - - [28/May/2024 12:28:25] "POST /finetune HTTP/1.1" 200 -
112547
127.0.0.1 - - [28/May/2024 12:28:25] "POST /finetune HTTP/1.1" 200 -
nerdylive
nerdylive6mo ago
Hmm you need to expose the port first I forgot how, please check the docs Then press connect on Runpod's website You'll get the link
Asad Cognify
Asad CognifyOP6mo ago
Thanks man. I forgot to expose the port. It worked now I have yet to test the python sdk. Will let you know if that worked
nerdylive
nerdylive6mo ago
Alr that's great
Asad Cognify
Asad CognifyOP6mo ago
@nerdylive The python sdk works. Thanks for that too.
nerdylive
nerdylive6mo ago
No problem bro
Want results from more Discord servers?
Add your server