R
RunPod•6mo ago
AC

JS pupeteer issue

Hi, I have a pupeteer chromium task that i want to run on the runpod which is written in typescript. I did not see any JS handler. So, i am calling the JS entrypoint via python as below.
""" Example handler file. """

import runpod
from subprocess import call
import os

# If your handler runs inference on a model, load the model here.
# You will want models to be loaded into memory before starting serverless.


def handler(job):
""" Handler function that will be used to process jobs. """
job_input = job['input']

prompt_id = job_input.get('aiPromptId')
video_save_path = job_input.get('videoSavePath')

# Create a copy of the current environment variables
env = os.environ.copy()

# Add or update the required environment variables
env['AI_PROMPT_ID'] = prompt_id
env['VIDEO_SAVE_PATH'] = video_save_path
print("env", env)

print("Running the executeDockerCommand")
# env['NODE_ENV'] = 'development'

call(["yarn", "ts-node", "src/backend/executeDockerCommand.ts"], env=env)

print("Finish running the command")

return f"Hello, {prompt_id}!"


runpod.serverless.start({"handler": handler})
""" Example handler file. """

import runpod
from subprocess import call
import os

# If your handler runs inference on a model, load the model here.
# You will want models to be loaded into memory before starting serverless.


def handler(job):
""" Handler function that will be used to process jobs. """
job_input = job['input']

prompt_id = job_input.get('aiPromptId')
video_save_path = job_input.get('videoSavePath')

# Create a copy of the current environment variables
env = os.environ.copy()

# Add or update the required environment variables
env['AI_PROMPT_ID'] = prompt_id
env['VIDEO_SAVE_PATH'] = video_save_path
print("env", env)

print("Running the executeDockerCommand")
# env['NODE_ENV'] = 'development'

call(["yarn", "ts-node", "src/backend/executeDockerCommand.ts"], env=env)

print("Finish running the command")

return f"Hello, {prompt_id}!"


runpod.serverless.start({"handler": handler})
The above code works fine locally. But, when i deploy to serverless, it kicks off the yarn ts-node ... , but gets stuck and does not emit any logs and eventually times out. Any advice?
25 Replies
nerdylive
nerdylive•6mo ago
Use codes block it's better to write code inside a code block This is how you write block code: ``` import subprocess import runpod ``` It will be like:
import subprocess
import runpod
import subprocess
import runpod
It does emit logs, if it does in your local when you call it manually in your command line But the logs from your process(cli you call using subprocess didn't go through runpod's log) So what you have to do is:
from runpod import RunPodLogger
# change this to your command ( also put this inside a handler code )
x = subprocess.run(["cmd", "/c", "dir"], capture_output=True)
# initialize the logger object
logger = RunPodLogger()
# log the output from your process
logger.info(f'{x.stdout.decode()}')
from runpod import RunPodLogger
# change this to your command ( also put this inside a handler code )
x = subprocess.run(["cmd", "/c", "dir"], capture_output=True)
# initialize the logger object
logger = RunPodLogger()
# log the output from your process
logger.info(f'{x.stdout.decode()}')
AC
ACOP•6mo ago
Awesome! Let me try that in the morning.
AC
ACOP•6mo ago
Looks like still stuck and does not emit log or proceeds
No description
nerdylive
nerdylive•6mo ago
It does It says it couldn't read that folder
AC
ACOP•6mo ago
i take that back. Its pupetteer launch issue. I am launching pupeteer with these options
const puppeteerLaunchOpts: PuppeteerLaunchOptions = {
// headless: shouldPerformanceTrace() ? false : 'shell',
headless: true,
devtools: isDev,
args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox'],
};

const browser = await puppeteer.launch(puppeteerLaunchOpts)
const puppeteerLaunchOpts: PuppeteerLaunchOptions = {
// headless: shouldPerformanceTrace() ? false : 'shell',
headless: true,
devtools: isDev,
args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox'],
};

const browser = await puppeteer.launch(puppeteerLaunchOpts)
Looks like this gets stuck
nerdylive
nerdylive•6mo ago
I c
AC
ACOP•6mo ago
It works fine locally 🤔 i am ssh'ing into the serverless and still seeing the same issue
nerdylive
nerdylive•6mo ago
whats the error? can you copy in text? maybe i can help
AC
ACOP•6mo ago
its just stuck
nerdylive
nerdylive•6mo ago
stuck in what? any logs?
AC
ACOP•6mo ago
There are no logs being emitted by puppeteer.launch I added logs before and after puppeteer.launch and the log after launch doesnt get triggered.
AC
ACOP•6mo ago
No description
nerdylive
nerdylive•6mo ago
is that warn normal or what
AC
ACOP•6mo ago
yea. thats normal it emits locally as well. Unrelated Has anyone ran pupeteer successfully?
nerdylive
nerdylive•6mo ago
hmm i dont know about that send me the full file maybe let me see
AC
ACOP•6mo ago
sure. Let me isolate keys and just keep the pupeteer code
AC
ACOP•6mo ago
This is the entire file
AC
ACOP•6mo ago
The entry point is generateAndUploadVideoViaPuppeteer
nerdylive
nerdylive•6mo ago
try dumpio = true on launchBrowser put it in args
AC
ACOP•6mo ago
got it! trying
nerdylive
nerdylive•6mo ago
whats the logs after
AC
ACOP•6mo ago
No description
AC
ACOP•6mo ago
Got this now Is there something i need to turn on gpu support via dockerfile?
nerdylive
nerdylive•6mo ago
no i dont think so search the problem up i think its like dependency problem only
AC
ACOP•6mo ago
Got it. Let me search around.
Want results from more Discord servers?
Add your server