<commit_before>package main

import (
	"errors"
	"flag"
	"fmt"
	"net"
	"strings"

	"github.com/enaml-ops/enaml"
)

// NetworkMover is a transformation that changes which network
// an instance group is placed in.
type NetworkMover struct {
	InstanceGroup string
	Network       string
	StaticIPs     []string
	ipsFlag       string
}

func (n *NetworkMover) Apply(dm *enaml.DeploymentManifest) error {
	ig := dm.GetInstanceGroupByName(n.InstanceGroup)
	if ig == nil {
		return fmt.Errorf("couldn't find instance group %s", n.InstanceGroup)
	}

	if l := len(ig.Networks); l != 1 {
		return fmt.Errorf("expected 1 network, found %d", l)
	}

	ig.Networks[0].Name = n.Network

	if len(n.StaticIPs) > 0 {
		ig.Networks[0].StaticIPs = n.StaticIPs
	}

	return nil
}

func (n *NetworkMover) flagSet() *flag.FlagSet {
	fs := flag.NewFlagSet("change-network", flag.ExitOnError)
	fs.StringVar(&n.InstanceGroup, "instance-group", "", "name of the instance group")
	fs.StringVar(&n.Network, "network", "", "the name of the network to use")
	fs.StringVar(&n.ipsFlag, "static-ips", "", "comma-separated list of static IP ranges to set on the network")
	return fs
}

// ChangeNetworkTransformation is a TransformationBuilder that builds the
// 'change-network' transformation.
func ChangeNetworkTransformation(args []string) (Transformation, error) {
	n := &NetworkMover{}
	fs := n.flagSet()
	err := fs.Parse(args)
	if err != nil {<commit_msg>updating tests for change network to not exit on error, but continue for tracing purposes<commit_after>package main

import (
	"errors"
	"flag"
	"fmt"
	"net"
	"strings"

	"github.com/enaml-ops/enaml"
)

// NetworkMover is a transformation that changes which network
// an instance group is placed in.
type NetworkMover struct {
	InstanceGroup string
	Network       string
	StaticIPs     []string
	ipsFlag       string
}

func (n *NetworkMover) Apply(dm *enaml.DeploymentManifest) error {
	ig := dm.GetInstanceGroupByName(n.InstanceGroup)
	if ig == nil {
		return fmt.Errorf("couldn't find instance group %s", n.InstanceGroup)
	}

	if l := len(ig.Networks); l != 1 {
		return fmt.Errorf("expected 1 network, found %d", l)
	}

	ig.Networks[0].Name = n.Network

	if len(n.StaticIPs) > 0 {
		ig.Networks[0].StaticIPs = n.StaticIPs
	}

	return nil
}

func (n *NetworkMover) flagSet() *flag.FlagSet {
	fs := flag.NewFlagSet("change-network", flag.ContinueOnError)
	fs.StringVar(&n.InstanceGroup, "instance-group", "", "name of the instance group")
	fs.StringVar(&n.Network, "network", "", "the name of the network to use")
	fs.StringVar(&n.ipsFlag, "static-ips", "", "comma-separated list of static IP ranges to set on the network")
	return fs
}

// ChangeNetworkTransformation is a TransformationBuilder that builds the
// 'change-network' transformation.
func ChangeNetworkTransformation(args []string) (Transformation, error) {
	n := &NetworkMover{}
	fs := n.flagSet()
	err := fs.Parse(args)
	if err != nil {
{'fraction_non_alphanumeric': 0.13139931740614336, 'fraction_numerical': 0.0034129692832764505, 'mean_word_length': 4.224598930481283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '869347', 'n_tokens_mistral': 1000, 'n_tokens_neox': 974, 'n_words': 284}