Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you run these actors locally? #3

Open
JamieMason opened this issue Jul 8, 2023 · 4 comments
Open

How do you run these actors locally? #3

JamieMason opened this issue Jul 8, 2023 · 4 comments

Comments

@JamieMason
Copy link

Thanks for this useful project starter, I'm trying to get going but having some trouble. If someone could point out where I'm going wrong and/or where I should be looking in the Docs that would be great, thank you.

Some things I've tried:

cd actors/typescript-actor && apify run seems to work:

[] ~/Dev/apify-actors/actors/typescript-actor <main> apify run  
Run: npm start

> @actors/typescript-actor@1.0.0 start
> node --no-warnings --experimental-specifier-resolution=node --loader ../../module_loader.js src/index.ts

INFO  System info {"apifyVersion":"3.1.7","apifyClientVersion":"2.7.1","crawleeVersion":"3.4.0","osType":"Darwin","nodeVersion":"v18.14.2"}
INFO  JavaScript utils say: Hello from a TypeScript actor!
INFO  TypeScript utils say: No message provided!

cd actors/typescript-actor && apify push seems to lose access to parent folders

[] ~/Dev/apify-actors/actors/typescript-actor <main> apify push
Info: Deploying actor 'example-monorepo-actor-typescript' to Apify.
Run: Updated version 0.0 for example-monorepo-actor-typescript actor.
Run: Building actor example-monorepo-actor-typescript
2023-07-08T10:41:22.773Z ACTOR: ERROR: Actor context path "../../.." is outside of actor root directory!
2023-07-08T10:41:22.773Z ACTOR: ERROR: Actor context path "../../.." is outside of actor root directory!
Actor build detail -> https://console.apify.com/actors/THboJ0Kp2vfnWdJdZ#/builds/0.0.2
? Do you want to open the actor detail in your browser? Yes
Error: Build failed!

I thought maybe apify push from the project root would resolve this, but it seems to create an empty/broken actor:

[] ~/Dev/apify-actors <main> apify push
Info: Created actor with name undefined on Apify.
Info: Deploying actor 'undefined' to Apify.
Run: Updated version 0.0 for my-actor actor.
Run: Building actor my-actor
2023-07-08T10:43:59.174Z ACTOR: Dockerfile not found, using the default one.
2023-07-08T10:43:59.182Z ACTOR: Extracting actor documentation from README.md
2023-07-08T10:43:59.185Z ACTOR: Did not find input schema at any of the default locations
2023-07-08T10:43:59.208Z ACTOR: Building Docker image.
2023-07-08T10:43:59.246Z Step 1/4 : FROM apify/actor-node:16
2023-07-08T10:43:59.474Z  ---> ac7d12e8de1e
2023-07-08T10:43:59.476Z Step 2/4 : COPY . ./
2023-07-08T10:43:59.570Z  ---> 98e2aed15b89
2023-07-08T10:43:59.572Z Step 3/4 : RUN npm install --quiet --only=prod --no-optional  && (npm list || true)
2023-07-08T10:43:59.583Z  ---> Running in f33d94016e16
2023-07-08T10:44:00.506Z npm
2023-07-08T10:44:00.508Z  WARN config only Use `--omit=dev` to omit dev dependencies from the install.
2023-07-08T10:44:00.510Z
2023-07-08T10:44:00.513Z npm WARN
2023-07-08T10:44:00.514Z  config optional Use `--omit=optional` to exclude optional dependencies, or
2023-07-08T10:44:00.517Z npm WARN
2023-07-08T10:44:00.519Z config
2023-07-08T10:44:00.521Z  `--include=optional` to include them.
2023-07-08T10:44:00.523Z npm WARN
2023-07-08T10:44:00.525Z config
2023-07-08T10:44:00.528Z
2023-07-08T10:44:00.530Z
2023-07-08T10:44:00.532Z npm WARN config     Default value does install optional deps unless otherwise omitted.
2023-07-08T10:44:00.534Z
2023-07-08T10:44:07.516Z added 5 packages, removed 133 packages, changed 11 packages, and audited 140 packages in 7s
2023-07-08T10:44:07.519Z 31 packages are looking for funding
2023-07-08T10:44:07.521Z   run `npm fund` for details
2023-07-08T10:44:07.523Z 1 moderate severity vulnerability
2023-07-08T10:44:07.526Z To address all issues, run:
2023-07-08T10:44:07.528Z   npm audit fix
2023-07-08T10:44:07.530Z Run `npm audit` for details.
2023-07-08T10:44:08.052Z apify-actor-monorepo@1.0.0 /usr/src/app
2023-07-08T10:44:08.054Z +-- @actors/javascript-actor@1.0.0 -> ./actors/javascript-actor
2023-07-08T10:44:08.056Z | +-- @packages/javascript-utils@1.0.0 deduped -> ./packages/javascript-utils
2023-07-08T10:44:08.059Z | `-- apify@3.1.7
2023-07-08T10:44:08.061Z +-- @actors/typescript-actor@1.0.0 -> ./actors/typescript-actor
2023-07-08T10:44:08.063Z | +-- @packages/javascript-utils@1.0.0 deduped -> ./packages/javascript-utils
2023-07-08T10:44:08.069Z | +-- @packages/typescript-utils@1.0.0 deduped -> ./packages/typescript-utils
2023-07-08T10:44:08.075Z | `-- apify@3.1.7 deduped
2023-07-08T10:44:08.077Z +-- @packages/javascript-utils@1.0.0 -> ./packages/javascript-utils
2023-07-08T10:44:08.080Z | `-- @apify/log@2.2.18
2023-07-08T10:44:08.081Z `-- @packages/typescript-utils@1.0.0 -> ./packages/typescript-utils
2023-07-08T10:44:08.083Z   `-- @apify/log@2.2.18 deduped
2023-07-08T10:44:08.952Z Removing intermediate container f33d94016e16
2023-07-08T10:44:08.954Z  ---> a33866cc294e
2023-07-08T10:44:08.956Z Step 4/4 : LABEL com.apify.actBuildId=8XbuAx6AGJdLwBVw1
2023-07-08T10:44:08.974Z  ---> Running in 5549be4cebe8
2023-07-08T10:44:09.030Z Removing intermediate container 5549be4cebe8
2023-07-08T10:44:09.033Z  ---> 2c39aeef9241
2023-07-08T10:44:09.035Z [Warning] One or more build-args [ACTOR_PATH_IN_DOCKER_CONTEXT] were not consumed
2023-07-08T10:44:09.038Z Successfully built 2c39aeef9241
2023-07-08T10:44:09.040Z Successfully tagged 031263542130.dkr.ecr.us-east-1.amazonaws.com/act-builds-prod-00155:8XbuAx6AGJdLwBVw1
2023-07-08T10:44:09.042Z ACTOR: Pushing Docker image to repository.
2023-07-08T10:44:11.050Z ACTOR: Build finished.
Actor build detail -> https://console.apify.com/actors/68cQMn1U29wVu81Dd#/builds/0.0.1
? Do you want to open the actor detail in your browser? Yes
Success: Actor was deployed to Apify cloud and built there.

and apify run from the root is similar

Error: The "npm start" script was not found in package.json. Please set it up for your project. For more information about that call "apify help run".

The readme mentions:

To enable testing the TypeScript Actors locally without having to rebuild them or the TypeScript packages after every code change, ts-node along with the tsconfig-paths loader is used. Since tsconfig-paths does not play well with ESM packages, a custom wrapper for the loader is used, defined in module_loader.js.

but I'm lacking some context, do we need to run ts-node -r tsconfig-paths/register <which file?>

Documentation I've read:

The apify CLI I installed via npm install -g apify-cli and is version apify-cli/0.17.0 darwin-x64 node-v18.14.2

That's everything I can think of, please let you know if you need anything else. Thanks.

@JamieMason
Copy link
Author

JamieMason commented Jul 24, 2023

Is there any more information I should provide? Please let me know and I will try to provide it. I'd be grateful if someone at Apify would acknowledge the issue, even if just to tell me it is not a priority to provide support with onboarding. I've also asked in your discord and had no reply.

@JJetmar
Copy link

JJetmar commented Jul 25, 2023

Hi @JamieMason ,
the full support for monorepos is currently still in development, but we already have a working prove of concept solution, that is what is this repository about.

This approach currently doesn't allow you to use apify push for deploying your local project to the platform. You need to set the Actor source to the git repository and build the actor from the GIT repository.

You need to be in the Actor's directory to be able to use apify run for running the Actor.

@avakil3
Copy link

avakil3 commented May 17, 2024

@JamieMason has this issue of not being able to apify push your local project to the platform been fixed? I'd like to be able to push my local project changes to my 2.0 dev version for testing purposes. We currently run Prod off 0.0 version.

@JamieMason
Copy link
Author

I was blocked and parked this @avakil3 but I would love to return to it. I'll reply here if I find anything to share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants