<commit_before><?php

return array(
	'arg0'    => 'db:seed',
	'command' => 'db:seed [<seed-file>]',
	'description' => 'Seed collections from YAML files.',
	'run' => function($args) use ($commands) {
		$seed_file = '*';

		if ($args[1]!==null) {
			$seed_file = $args[1] . '.yaml';
		}

		$client = new Client\Client();
		foreach(\Client\Utils::glob(Client\Project::root() . 'dl-ext/seeds/' . $seed_file) as $yaml_file) {
			$collection = basename($yaml_file, '.yaml');

			$yaml = new Symfony\Component\Yaml\Parser();
			$options = $yaml->parse(file_get_contents($yaml_file));

			if (isset($options['truncate']) && $options['truncate']) {
				echo "Truncating '{$collection}'... ";
				$truncate = $client->delete('collection/' . $collection);
				if (count($truncate)>0) {
					echo "ok.";
				}
				echo PHP_EOL;
			}

			if (isset($options['data']) && $options['data']) {
				$current_row = 0;
				$total_rows = count($options['data']);
				foreach($options['data'] as $data) {
					$client->post('collection/' . $collection, array('data' => $data));
					$current_row += 1;
					$percent = round(($current_row / $total_rows)*100);
					echo "Seeding '{$collection}': " . "{$percent}%" . str_repeat("\r", strlen($percent)+1);<commit_msg>YAML file seeding base, fix broken .yaml file lookup. #68<commit_after><?php

return array(
	'arg0'    => 'db:seed',
	'command' => 'db:seed [<seed-file>]',
	'description' => 'Seed collections from YAML files.',
	'run' => function($args) use ($commands) {
		$seed_file = '*.yaml';

		// if ($args[1] !== null) {
		// 	$seed_file = $args[1] . '.yaml';
		// }

		$client = new Client\Client();
		foreach(\Client\Utils::glob(Client\Project::root() . 'dl-ext/seeds/' . $seed_file) as $yaml_file) {
			$collection = basename($yaml_file, '.yaml');

			$yaml = new Symfony\Component\Yaml\Parser();
			$options = $yaml->parse(file_get_contents($yaml_file));

			if (isset($options['truncate']) && $options['truncate']) {
				echo "Truncating '{$collection}'... ";
				$truncate = $client->delete('collection/' . $collection);
				if (count($truncate)>0) {
					echo "ok.";
				}
				echo PHP_EOL;
			}
			if (isset($options['data']) && $options['data']) {
				$current_row = 0;
				$total_rows = count($options['data']);
				foreach($options['data'] as $data) {

					// Look for special data fields
					foreach($data as $key => $value) {
						if(is_array($value) && $value["upload"]){
							$data[$key] = $value["upload"];
						}
					}

					$client->post('collection/' . $collection, array('data' => $data));
					$current_row += 1;
					$percent = round(($current_row / $total_rows)*100);
					echo "Seeding '{$collection}': " . "{$percent}%" . str_repeat("\r", strlen($percent)+1);
{'fraction_non_alphanumeric': 0.2266715650257164, 'fraction_numerical': 0.008082292432035268, 'mean_word_length': 3.6706689536878216, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 24, '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': '2215306', 'n_tokens_mistral': 1122, 'n_tokens_neox': 934, 'n_words': 183}