Giter Club home page Giter Club logo

simple-dask-example's Introduction

simple-dask-example

Simple dask example using the Localstack.

Python Localstack Examples

This repo is to showcase how to use localstack with Python

Create new virtual envionment to run examples against localstack docker venv. Execution of your code can be done in docker as well.

$ cd localstack_service

$ docker-compose build --no-cache 

$ docker-compose up --scale dask-worker=4

Dask Notes

Dask dashboard Url: http://localhost:8787/status

Dask client Url : http://localhost:8786

When working with Dask the worker package versions should match with your client. Where client is your code that invokes your dask workers via the scheduler. In the examples shown client packages are stored in requirements.txt while dask packages are in conda environment.yml file

Python version is set to 3.8.3 in condo environment.yml. You may change this if you wish to match with your client version or change your client version.

Persisting data across restarts

Localstack's docker container lets you configure the data directory and put it in a mounted volume.

This means data for Kinesis, DynamoDB, Elasticsearch, S3 gets kept across container restarts. This is not the default behaviour.

We can enable this with an environment variable set DATA_DIR=/tmp/localstack/data, or we can hardcode our preferred DATA_DIR into the docker-compose file:

  • DATA_DIR=/tmp/localstack/data

Understanding some of the environment variables

SERVICES=${SERVICES- }

PORT_WEB_UI=${PORT_WEB_UI- }

HOST_TMP_FOLDER

Accessing your localstack with your AWS CLI

Each of your aws cli commands should consist of the endpoint url in the below example am using aws named profile which sets my default access and secret key

aws --endpoint-url=http://localhost:4572 s3 ls "s3://nyc-tlc/trip data/" --profile localstack

~/.aws/credentials

[localstack]
aws_access_key_id = foo
aws_secret_access_key = bar

~/.aws/config

[profile localstack]
region = us-east-1
output = json

Serverless deploy steps

$ npm install -g serverless

$ npm install

$ npm link    

$ serverless deploy --stage local  --profile localstack

$ serverless invoke --function currentTime --log --profile localstack --stage local

The URL pattern for API Gateway localstack executions is

http://localhost:4566/restapis/<apiId>/<stage>/_user_request_/<methodPath>

This would map to below

$ curl http://localhost:4567/restapis/4d0hum90mq/local/_user_request_/ping

Localstack health check

curl http://localhost:4566/health

Take note initial run of your rest api calls may take sometime

{
  "services": {
    "cloudformation": "running",
    "cloudwatch": "running",
    "iam": "running",
    "sts": "running",
    "lambda": "running",
    "logs": "running",
    "s3": "running",
    "sqs": "running",
    "events": "running",
    "apigateway": "running"
  }
}

Want to contribute ?

Feel free to raise A PR with new examples

simple-dask-example's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.