<commit_before>package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"sync"
	"time"

	"code.google.com/p/go-uuid/uuid"
	"github.com/gorilla/mux"
	"github.com/lxc/lxd/shared"
)

var lock sync.Mutex
var operations map[string]*shared.Operation

func CreateOperation(metadata shared.Jmap, run func() shared.OperationResult, cancel func() error, ws shared.OperationSocket) (string, error) {
	id := uuid.New()
	op := shared.Operation{}
	op.CreatedAt = time.Now()
	op.UpdatedAt = op.CreatedAt
	op.SetStatus(shared.Pending)
	op.ResourceURL = shared.OperationsURL(id)

	md, err := json.Marshal(metadata)
	if err != nil {
		return "", err
	}
	op.Metadata = md

	op.MayCancel = cancel != nil

	op.Run = run
	op.Cancel = cancel
	op.Chan = make(chan bool, 1)
	op.WebsocketConnected = false<commit_msg>Ops, restore mistakenly removed make call<commit_after>package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"sync"
	"time"

	"code.google.com/p/go-uuid/uuid"
	"github.com/gorilla/mux"
	"github.com/lxc/lxd/shared"
)

var lock sync.Mutex
var operations map[string]*shared.Operation = make(map[string]*shared.Operation)

func CreateOperation(metadata shared.Jmap, run func() shared.OperationResult, cancel func() error, ws shared.OperationSocket) (string, error) {
	id := uuid.New()
	op := shared.Operation{}
	op.CreatedAt = time.Now()
	op.UpdatedAt = op.CreatedAt
	op.SetStatus(shared.Pending)
	op.ResourceURL = shared.OperationsURL(id)

	md, err := json.Marshal(metadata)
	if err != nil {
		return "", err
	}
	op.Metadata = md

	op.MayCancel = cancel != nil

	op.Run = run
	op.Cancel = cancel
	op.Chan = make(chan bool, 1)
	op.WebsocketConnected = false
{'fraction_non_alphanumeric': 0.14277071990320628, 'fraction_numerical': 0.0012099213551119178, 'mean_word_length': 4.284345047923322, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2923982', 'n_tokens_mistral': 609, 'n_tokens_neox': 601, 'n_words': 133}