-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #3
- Loading branch information
Showing
6 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "e77e0d17", | ||
"metadata": {}, | ||
"source": [ | ||
"This script is taken from the [AWS Glue documentation](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-libraries.html#develop-local-docker-image)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "16d841a2-02e6-4f4a-9f4d-29d03f0cbf79", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import sys\n", | ||
"\n", | ||
"from awsglue import DynamicFrame\n", | ||
"from awsglue.context import GlueContext\n", | ||
"from awsglue.job import Job\n", | ||
"from awsglue.utils import getResolvedOptions\n", | ||
"from pyspark.context import SparkContext\n", | ||
"\n", | ||
"\n", | ||
"class GluePythonSampleTest:\n", | ||
" def __init__(self) -> None:\n", | ||
" params = []\n", | ||
" if \"--JOB_NAME\" in sys.argv:\n", | ||
" params.append(\"JOB_NAME\")\n", | ||
" args = getResolvedOptions(sys.argv, params)\n", | ||
"\n", | ||
" self.context = GlueContext(SparkContext.getOrCreate())\n", | ||
" self.job = Job(self.context)\n", | ||
"\n", | ||
" jobname = args.get(\"JOB_NAME\", \"test\")\n", | ||
" self.job.init(jobname, args)\n", | ||
"\n", | ||
" def run(self) -> None:\n", | ||
" dyf = read_json(\n", | ||
" self.context,\n", | ||
" \"s3://awsglue-datasets/examples/us-legislators/all/persons.json\",\n", | ||
" )\n", | ||
" dyf.printSchema()\n", | ||
"\n", | ||
" self.job.commit()\n", | ||
"\n", | ||
"\n", | ||
"def read_json(glue_context: GlueContext, path: str) -> DynamicFrame:\n", | ||
" return glue_context.create_dynamic_frame.from_options(\n", | ||
" connection_type=\"s3\",\n", | ||
" connection_options={\"paths\": [path], \"recurse\": True},\n", | ||
" format=\"json\",\n", | ||
" )\n", | ||
"\n", | ||
"\n", | ||
"GluePythonSampleTest().run()\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "PySpark", | ||
"language": "python", | ||
"name": "pysparkkernel" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "python", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "pyspark", | ||
"pygments_lexer": "python3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters