|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "from sagemaker.processing import ScriptProcessor, ProcessingInput, ProcessingOutput" |
| 10 | + ] |
| 11 | + }, |
| 12 | + { |
| 13 | + "cell_type": "code", |
| 14 | + "execution_count": null, |
| 15 | + "metadata": {}, |
| 16 | + "outputs": [], |
| 17 | + "source": [ |
| 18 | + "script_processor = ScriptProcessor(\n", |
| 19 | + " command=['python3'],\n", |
| 20 | + " image_uri='<account_number>.dkr.ecr.<region>.amazonaws.com/aws-sagemaker-hamilton:latest', # Change to the actual URI\n", |
| 21 | + " role='arn:aws:iam::<account_number>:role/SageMakerScriptProcessorRole', # Change to the actual URI\n", |
| 22 | + " instance_count=1,\n", |
| 23 | + " instance_type='ml.t3.medium'\n", |
| 24 | + ")" |
| 25 | + ] |
| 26 | + }, |
| 27 | + { |
| 28 | + "cell_type": "code", |
| 29 | + "execution_count": null, |
| 30 | + "metadata": {}, |
| 31 | + "outputs": [], |
| 32 | + "source": [ |
| 33 | + "# All inputs and outputs should be located in /opt/ml/processing/\n", |
| 34 | + "script_processor.run(\n", |
| 35 | + " code='processing.py',\n", |
| 36 | + " inputs=[\n", |
| 37 | + " ProcessingInput(\n", |
| 38 | + " source='data/',\n", |
| 39 | + " destination='/opt/ml/processing/input/data'\n", |
| 40 | + " ),\n", |
| 41 | + " ProcessingInput(\n", |
| 42 | + " source='app/',\n", |
| 43 | + " destination='/opt/ml/processing/input/code/app'\n", |
| 44 | + " )\n", |
| 45 | + " ],\n", |
| 46 | + " outputs=[\n", |
| 47 | + " ProcessingOutput(\n", |
| 48 | + " source='/opt/ml/processing/output/',\n", |
| 49 | + " destination='s3://path/to/output/directory' # Change to the actual URI\n", |
| 50 | + " )\n", |
| 51 | + " ]\n", |
| 52 | + ")" |
| 53 | + ] |
| 54 | + }, |
| 55 | + { |
| 56 | + "cell_type": "markdown", |
| 57 | + "metadata": {}, |
| 58 | + "source": [ |
| 59 | + "After job finishes, the new files will appear in `s3://path/to/output/directory`:\n", |
| 60 | + "- `output_table.csv`\n", |
| 61 | + "- `dag_visualization.svg`" |
| 62 | + ] |
| 63 | + } |
| 64 | + ], |
| 65 | + "metadata": { |
| 66 | + "kernelspec": { |
| 67 | + "display_name": "hamilton", |
| 68 | + "language": "python", |
| 69 | + "name": "python3" |
| 70 | + }, |
| 71 | + "language_info": { |
| 72 | + "codemirror_mode": { |
| 73 | + "name": "ipython", |
| 74 | + "version": 3 |
| 75 | + }, |
| 76 | + "file_extension": ".py", |
| 77 | + "mimetype": "text/x-python", |
| 78 | + "name": "python", |
| 79 | + "nbconvert_exporter": "python", |
| 80 | + "pygments_lexer": "ipython3", |
| 81 | + "version": "3.11.8" |
| 82 | + } |
| 83 | + }, |
| 84 | + "nbformat": 4, |
| 85 | + "nbformat_minor": 2 |
| 86 | +} |
0 commit comments