Open in app
Home
Notifications
Lists
Stories

Write
diary of a codelovingyogi
diary of a codelovingyogi

Home

Sep 19, 2021

merging multiple partitions on thumb drive

For whatever reason, my thumb drive got partitioned into several pieces making it hard to use. In windows you can do the following: open the windows command prompt type diskpart , it opens a separate command window type list disk identify your removable disk, you can confirm by going into…

1 min read


Jun 24, 2021

prefect dag scheduling — cloud

October 20, 2020 trying out prefect cloud features to determine deployment strategy for productionalizing workflows logged into prefect cloud created a new project in the Team section: then Projects :

3 min read

prefect dag scheduling — cloud
prefect dag scheduling — cloud

Jun 22, 2021

weekly misc items: October 12, 2020

mocking lambda invoke from moto import mock_iam, mock_lambda def get_role_name(): with mock_iam(): iam = boto3.client("iam", region_name=_lambda_region) try: return iam.get_role(RoleName="my-role")["Role"]["Arn"] except ClientError: return iam.create_role( RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/", )["Role"]["Arn"]

3 min read

weekly misc items: October 12, 2020
weekly misc items: October 12, 2020

Jun 19, 2021

weekly misc items: October 5, 2020

noting here for reference — moto for mocking aws secrets manager from moto import mock_secretsmanager @pytest.fixture @mock_secretsmanager def mock_response(): mock_secretsmanager().start() sm_client = boto3.client('secretsmanager') response = sm_client.put_secret_value( SecretId='<aws-secrets-name>', SecretString='<secrets-string>' ) 2. import pendulum 3. mocking aws athena

1 min read


Jun 17, 2021

prefect dag scheduling — repo strategy

October 6, 2020 thinking about creating a separate task for each repo we have. each repo usually stores the code for its lambda execution code. …

2 min read

prefect dag scheduling — repo strategy
prefect dag scheduling — repo strategy

Jun 14, 2021

prefect dag scheduling — adding schedules

October 5, 2020 upon reading documentation, adding a schedule for your flow is as easy as: import datetime from prefect.schedules import IntervalSchedule schedule = IntervalSchedule(interval=datetime.timedelta(minutes=2)) flow = Flow('workflow-name', schedule) similarly adding a cron schedule would be: from prefect.schedules import CronSchedule daily_schedule = CronSchedule("0 8 * * *") flow = Flow('workflow-name', daily_schedule)…

2 min read

prefect dag scheduling — adding schedules
prefect dag scheduling — adding schedules

Jun 13, 2021

weekly misc items: September 21, 2020

reading multiple s3 files into pyspark file_paths = '<bucket-name>/<filepath>/<object-name>1.json,<bucket-name>/<filepath>/<object-name>2.json' file_paths_list = [f"s3a://{file}" for file in file_paths.split(',')] df = spark.read.format("json").load(queued_files_list) # or df_merged_schema = spark.read.option("mergeSchema", "true").format('json').load(queued_files_list) 2. display spark sql display(spark.sql("""<sql statement>"""))

1 min read


Jun 12, 2021

weekly misc items: September 28, 2020

aws assuming roles/switching account: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html export AWS_PROFILE=default-prod 2. you can unset env var: unset AWS_PROFILE 3. invoke lambda function via cli aws lambda invoke --function-name <lambda-function-name> --payload '{"key": "value"}' out get logs: sed -i'' -e 's/"//g' out sleep 15 aws logs get-log-events --log-group-name /aws/lambda/my-function --log-stream-name $(cat out) --limit 5

1 min read

weekly misc items: September 28, 2020

  1. aws assuming roles/switching account:

https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

export AWS_PROFILE=default-prod

2. you can unset env var:

unset AWS_PROFILE

3. invoke lambda function via cli

aws lambda invoke --function-name <lambda-function-name> --payload '{"key": "value"}'  out

get logs:

sed -i'' -e 's/"//g' out
sleep 15
aws logs get-log-events --log-group-name /aws/lambda/my-function --log-stream-name $(cat out) --limit 5

4. assume role for local invoke of lambda function:

https://docs.aws.amazon.com/code-samples/latest/catalog/python-sts-sts_temporary_credentials-assume_role_mfa.py.html

--

--


Jun 9, 2021

prefect dag scheduling — invoke lambda, logging

September 28, 2020 continuing with work i’m doing to complete a proof of concept (poc) using prefect as our dag scheduler install prefect extras: pip install "prefect[aws]" adding secrets: export PREFECT__TASKS__DEFAULTS__MAX_RETRIES=4 read secrets from code: import prefect max_retries = prefect.config.tasks.defaults.max_retries adding aws credentials: export PREFECT__CONTEXT__SECRETS__AWS_CREDENTIALS='{"ACCESS_KEY": "<access_key>", "SECRET_ACCESS_KEY": "<secret_access_key>"}'

3 min read

prefect dag scheduling — invoke lambda, logging
prefect dag scheduling — invoke lambda, logging

Apr 5, 2021

prefect dag scheduling — backend server, tasks, flow setup

September 10, 2020 working on a dag scheduler proof-of-concept (POC) using prefect docker run -it prefecthq/prefect:latest i did not have image locally, so docker pulls the latest for me (note this image will bring you directly into python interpreter) docker images to see the prefect image: to run backend server: …

4 min read

prefect dag scheduling — backend server, tasks, flow setup
prefect dag scheduling — backend server, tasks, flow setup
diary of a codelovingyogi

diary of a codelovingyogi

quick notes, snippets, bugs, and fixes

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Knowable