Skip to content

Commit

Permalink
M1: fix inconsistencies in code - Python Hello World (#38)
Browse files Browse the repository at this point in the history
* fix inconsistencies in code

* remove broken link

* add meta description
  • Loading branch information
fakela committed Dec 16, 2022
1 parent 0e76533 commit a1211fa
Showing 1 changed file with 148 additions and 55 deletions.
203 changes: 148 additions & 55 deletions workload-onboarding/trivial-python/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"---\n",
"sidebar_label: \"Python - Hello World\"\n",
"sidebar_position: 1\n",
"description: How to run a Python file hosted on Bacalhau\n",
"---"
]
},
Expand Down Expand Up @@ -45,7 +46,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 5,
"metadata": {
"tags": []
},
Expand All @@ -54,7 +55,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"env: PATH=./:./:./:/Users/phil/.pyenv/versions/3.9.7/bin:/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/Users/phil/.gvm/bin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/coreutils/libexec/gnubin:/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/Users/phil/.pyenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/Users/phil/.nexustools\n"
"env: PATH=./:./:/home/gitpod/.pyenv/versions/3.8.13/bin:/home/gitpod/.pyenv/libexec:/home/gitpod/.pyenv/plugins/python-build/bin:/home/gitpod/.pyenv/plugins/pyenv-virtualenv/bin:/home/gitpod/.pyenv/plugins/pyenv-update/bin:/home/gitpod/.pyenv/plugins/pyenv-installer/bin:/home/gitpod/.pyenv/plugins/pyenv-doctor/bin:/home/gitpod/.pyenv/shims:/ide/bin/remote-cli:/home/gitpod/.nix-profile/bin:/home/gitpod/.local/bin:/home/gitpod/.sdkman/candidates/maven/current/bin:/home/gitpod/.sdkman/candidates/java/current/bin:/home/gitpod/.sdkman/candidates/gradle/current/bin:/workspace/.cargo/bin:/home/gitpod/.rvm/gems/ruby-3.1.2/bin:/home/gitpod/.rvm/gems/ruby-3.1.2@global/bin:/home/gitpod/.rvm/rubies/ruby-3.1.2/bin:/home/gitpod/.pyenv/plugins/pyenv-virtualenv/shims:/home/gitpod/.pyenv/shims:/workspace/go/bin:/home/gitpod/.nix-profile/bin:/ide/bin/remote-cli:/home/gitpod/go/bin:/home/gitpod/go-packages/bin:/home/gitpod/.nvm/versions/node/v16.18.1/bin:/home/gitpod/.yarn/bin:/home/gitpod/.pnpm:/home/gitpod/.pyenv/bin:/workspace/.rvm/bin:/home/gitpod/.cargo/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin/:/home/gitpod/.local/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/gitpod/.nvm/versions/node/v16.18.1/bin:/home/gitpod/.rvm/bin\n"
]
}
],
Expand All @@ -77,7 +78,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 6,
"metadata": {
"tags": []
},
Expand Down Expand Up @@ -112,45 +113,15 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 7,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Job successfully submitted. Job ID: 15f57de4-4ea1-45ca-899d-fba08fb53420\n",
"Checking job status... (Enter Ctrl+C to exit at any time, your job will continue running):\n",
"\n",
"\t Creating job for submission ... done ✅\n",
"\t Finding node(s) for the job ... done ✅\n",
"\t Node accepted the job ... done ✅\n",
"\t Job finished, verifying results ... done ✅\n",
"\t Results accepted, publishing ... done ✅\n",
"\t \n",
"Results CID: QmehTNF6ogbESt26EgrSw9YGrApneSWhPesqw1A5T6ezBe\n",
"Job Results By Node:\n",
"Node QmXaXu9N:\n",
" Shard 0:\n",
" Status: Completed\n",
" Container Exit Code: 0\n",
" Stdout:\n",
" Hello, world!\n",
" Stderr: <NONE>\n",
"\n",
"To download the results, execute:\n",
" bacalhau get 15f57de4-4ea1-45ca-899d-fba08fb53420\n",
"\n",
"To get more details about the run, execute:\n",
" bacalhau describe 15f57de4-4ea1-45ca-899d-fba08fb53420\n"
]
}
],
"outputs": [],
"source": [
"%%bash\n",
"%%bash --out job_id\n",
"bacalhau docker run \\\n",
" --id-only \\\n",
" --input-urls https://raw.githubusercontent.com/bacalhau-project/examples/151eebe895151edd83468e3d8b546612bf96cd05/workload-onboarding/trivial-python/hello-world.py \\\n",
" python:3.10-slim -- python3 /inputs/hello-world.py"
]
Expand All @@ -171,11 +142,118 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"env: JOB_ID=bde362b4-cc5a-4c3a-8042-122cc3c0c2ea\n"
]
}
],
"source": [
"bacalhau get ${JOB_ID}"
"%env JOB_ID={job_id}"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"APIVersion: V1beta1\n",
"Metadata:\n",
" ClientID: 81568beeb7c8626d4565627ca0fd4b76fd18fec20a37c3b6a9b02bc03cbce5ae\n",
" CreatedAt: \"2022-12-14T11:01:02.501686348Z\"\n",
" ID: bde362b4-cc5a-4c3a-8042-122cc3c0c2ea\n",
"Spec:\n",
" Deal:\n",
" Concurrency: 1\n",
" Docker:\n",
" Entrypoint:\n",
" - python3\n",
" - /inputs/hello-world.py\n",
" Image: python:3.10-slim\n",
" Engine: Docker\n",
" ExecutionPlan:\n",
" ShardsTotal: 1\n",
" Language:\n",
" JobContext: {}\n",
" Publisher: Estuary\n",
" Resources:\n",
" GPU: \"\"\n",
" Sharding:\n",
" BatchSize: 1\n",
" GlobPatternBasePath: /inputs\n",
" Timeout: 1800\n",
" Verifier: Noop\n",
" Wasm: {}\n",
" inputs:\n",
" - StorageSource: URLDownload\n",
" URL: https://raw.githubusercontent.com/bacalhau-project/examples/151eebe895151edd83468e3d8b546612bf96cd05/workload-onboarding/trivial-python/hello-world.py\n",
" path: /inputs\n",
" outputs:\n",
" - Name: outputs\n",
" StorageSource: IPFS\n",
" path: /outputs\n",
"Status:\n",
" JobState:\n",
" Nodes:\n",
" QmVAb7r2pKWCuyLpYWoZr9syhhFnTWeFaByHdb8PkkhLQG:\n",
" Shards:\n",
" \"0\":\n",
" NodeId: QmVAb7r2pKWCuyLpYWoZr9syhhFnTWeFaByHdb8PkkhLQG\n",
" PublishedResults:\n",
" CID: QmehTNF6ogbESt26EgrSw9YGrApneSWhPesqw1A5T6ezBe\n",
" Name: job-bde362b4-cc5a-4c3a-8042-122cc3c0c2ea-shard-0-host-QmVAb7r2pKWCuyLpYWoZr9syhhFnTWeFaByHdb8PkkhLQG\n",
" StorageSource: IPFS\n",
" RunOutput:\n",
" exitCode: 0\n",
" runnerError: \"\"\n",
" stderr: \"\"\n",
" stderrtruncated: false\n",
" stdout: |\n",
" Hello, world!\n",
" stdouttruncated: false\n",
" State: Completed\n",
" VerificationResult:\n",
" Complete: true\n",
" Result: true\n",
" QmXaXu9N5GNetatsvwnTfQqNtSeKAD6uCmarbh3LMRYAcF:\n",
" Shards:\n",
" \"0\":\n",
" NodeId: QmXaXu9N5GNetatsvwnTfQqNtSeKAD6uCmarbh3LMRYAcF\n",
" PublishedResults: {}\n",
" State: Cancelled\n",
" VerificationResult: {}\n",
" QmYgxZiySj3MRkwLSL4X2MF5F9f2PMhAE3LV49XkfNL1o3:\n",
" Shards:\n",
" \"0\":\n",
" NodeId: QmYgxZiySj3MRkwLSL4X2MF5F9f2PMhAE3LV49XkfNL1o3\n",
" PublishedResults: {}\n",
" State: Cancelled\n",
" VerificationResult: {}\n",
" QmdZQ7ZbhnvWY1J12XYKGHApJ6aufKyLNSvf8jZBrBaAVL:\n",
" Shards:\n",
" \"0\":\n",
" NodeId: QmdZQ7ZbhnvWY1J12XYKGHApJ6aufKyLNSvf8jZBrBaAVL\n",
" PublishedResults: {}\n",
" State: Cancelled\n",
" VerificationResult: {}\n",
" Requester:\n",
" RequesterNodeID: QmYgxZiySj3MRkwLSL4X2MF5F9f2PMhAE3LV49XkfNL1o3\n",
" RequesterPublicKey: CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDF5pYaTdt4UwzslPRDr8XFXv1clttGGIWENlnECLVqswrQVp5xrMsI/57MrJUsMADsz6a/cip9LOxiym3bZVIeZ5WmbrFp48F0Wb7RCELAsUcl/zx4FHCK+A2FKqmuhpY9NyVNGupIDBUCPvCWsDb87Ur//a9BdCOETuab4577e3vFCa3fE+9jn5Fuhoa0m5Z7GfuZtU0W2FX6nc4VIfseMWrWpHD+Bqe/kXs+8RFBVW2AYyzO8lCcHtRC4Lb1Ml1V5hcoAN1pe5yfVuPlT9qyAgCnH3nIIWtvEYz8BnSDgXXTHdT+N+6lrm9oMglNh7TpT6ZbmpioIbJalelAyhG3AgMBAAE=\n"
]
}
],
"source": [
"%%bash\n",
"bacalhau describe ${JOB_ID}"
]
},
{
Expand All @@ -188,13 +266,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fetching results of job 'bde362b4-cc5a-4c3a-8042-122cc3c0c2ea'...\n",
"Results for job 'bde362b4-cc5a-4c3a-8042-122cc3c0c2ea' have been written to...\n",
"results\n"
]
}
],
"source": [
"mkdir -p new/myfolder\n",
"cd new/myfolder\n",
"bacalhau get ${JOB_ID}"
"%%bash\n",
"rm -rf results && mkdir results\n",
"bacalhau get ${JOB_ID} --output-dir results"
]
},
{
Expand All @@ -209,12 +297,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello, world!\n"
]
}
],
"source": [
"❯ cat new/myfolder/job-id/combined_results/stdout\n",
"Hello, World!"
"\n",
"%%bash\n",
"cat results/combined_results/stdout\n"
]
},
{
Expand All @@ -224,11 +321,7 @@
"source": [
"## Need Support?\n",
"\n",
"If have questions or need support or guidance, please reach out to the [Bacalhau team via Slack (#bacalhau channel)](https://filecoin.io/slack)\n",
"\n",
"## Contributing\n",
"\n",
"If you have any hints, tips or suggestions to add, check out the different [ways to contribute to Bacalhau](/docs/community/ways-to-contribute.md)."
"If have questions or need support or guidance, please reach out to the [Bacalhau team via Slack (#bacalhau channel)](https://filecoin.io/slack)\n"
]
}
],
Expand All @@ -248,7 +341,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13 (default, Oct 4 2022, 14:00:32) \n[GCC 9.4.0]"
"version": "3.8.13"
},
"orig_nbformat": 4,
"vscode": {
Expand Down

0 comments on commit a1211fa

Please sign in to comment.