<commit_before>#!/usr/bin/env python
# -*- encoding: utf-8
"""
Start/stop all the instances in an autoscaling group.

Usage: toggle_asg.py --name=<NAME> (--start | --stop)

Options:
  --name=<NAME>     Name of the autoscaling group.

Actions:
  --start           Start the autoscaling group (set the desired count to 1).
  --stop            Stop the autoscaling group (set the desired count to 0).

"""

import docopt


if __name__ == '__main__':
    args = docopt.docopt(__doc__)
<commit_msg>data_science: finish a script for toggling the ASG size<commit_after>#!/usr/bin/env python
# -*- encoding: utf-8
"""
Start/stop all the instances in an autoscaling group.

Usage: toggle_asg.py --name=<NAME> (--start | --stop)

Options:
  --name=<NAME>     Name of the autoscaling group.

Actions:
  --start           Start the autoscaling group (set the desired count to 1).
  --stop            Stop the autoscaling group (set the desired count to 0).

"""

import sys

import boto3
import docopt


if __name__ == '__main__':
    args = docopt.docopt(__doc__)

    asg_name = args['--name']

    if args.get('--start'):
        desired_size = 1
    elif args.get('--stop'):
        desired_size = 0
    else:
        print('Neither --start nor --stop flags supplied?  args=%r' % args)
        sys.exit(1)

    asg_client = boto3.client('autoscaling')
    asg_client.update_auto_scaling_group(
        AutoScalingGroupName=asg_name,
        MinSize=desired_size,
        MaxSize=desired_size,
        DesiredCapacity=desired_size,
    )

{'fraction_non_alphanumeric': 0.1209941137998692, 'fraction_numerical': 0.007194244604316547, 'mean_word_length': 2.6956521739130435, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1345724', 'n_tokens_mistral': 522, 'n_tokens_neox': 500, 'n_words': 147}