def mainnn(sup, input_file, output_file): min_support = float(sup) #min_support = 0.1 #input_file = "sample2.in" #input_file = "test.txt" #output_file = "outtest.txt" freq_dictionary, sort_list, file_len = Frequent(input_file, min_support) buying_table = sort_buying(input_file, freq_dictionary) #print(sort_list) #print(buying_table) rootTree, header_list = BuildTree(buying_table, sort_list) pattern_list = [] pattern_list = findpatternlist(rootTree, header_list, (file_len * min_support), set([]), pattern_list) #print(pattern_list) #need transfer into total_table, key:length of pattern, value:[ [pattern], count ] #print(header_list) total_table = {} for now_pat in pattern_list: now_pat[0] = sorted(now_pat[0]) if (len(now_pat[0]) in total_table): total_table[len(now_pat[0])].append(now_pat) else: total_table[len(now_pat[0])] = [now_pat] #print(total_table) #print(file_len*min_support) """ f = open(output_file, 'w', encoding = 'UTF-8') sort_list = sorted(sort_list, key = lambda x : int(x[0])) #print(sort_list) for i in sort_list: f.write("{0}:{1}\n".format(i[0],TrueRound(i[1]/file_len,4))) f.close() """ #total_table = findPattern(header_list, min_support*file_len) #print("------------------\n") #cnt = 0 f = open(output_file, 'w', encoding='UTF-8') for i in total_table: total_table[i] = sorted(total_table[i], key=lambda x: x[0]) #print(total_table[i]) for j in total_table[i]: #cnt=cnt+1 f.write(str(j[0][0])) for k in range(1, len(j[0])): #print(',{0}'.format(str(j[0][k]))) f.write(',{0}'.format(str(j[0][k]))) #print(":{:.4f}\n".format((TrueRound(int(j[1])/file_len,4)),4)) f.write(":{:.4f}\n".format((TrueRound(int(j[1]) / file_len, 4)), 4)) #print("{0}:{1}".format((','.join(str(j[0]))),TrueRound(int(j[1])/file_len,4))) #print(cnt) f.close()
def build_env(arg_strings=None): ''' Entry function. ''' parser = make_parser() args = parser.parse_args(arg_strings) if args.docker_build: return docker_build.build_with_docker(args.output_folder, sys.argv) result = 0 common_package_build_args = [] common_package_build_args += [ "--output_folder", os.path.abspath(args.output_folder) ] common_package_build_args += [ "--channel", os.path.abspath(args.output_folder) ] common_package_build_args += [ "--conda_build_config", os.path.abspath(args.conda_build_config) ] for channel in args.channels_list: common_package_build_args += ["--channels", channel] # If repository_folder doesn't exist, create it if args.repository_folder and not os.path.exists(args.repository_folder): os.mkdir(args.repository_folder) # Create the build tree try: build_tree = BuildTree( env_config_files=args.env_config_file, python_versions=utils.parse_arg_list(args.python_versions), build_types=utils.parse_arg_list(args.build_types), repository_folder=args.repository_folder, git_location=args.git_location, git_tag_for_env=args.git_tag_for_env, conda_build_config=args.conda_build_config) except OpenCEError as err: print(err.msg) return 1 # Build each package in the packages list for build_command in build_tree: build_args = common_package_build_args + build_command.feedstock_args() result = build_feedstock.build_feedstock(build_args) if result != 0: print("Unable to build recipe: " + build_command.repository) return result return result
def build_env(arg_strings=None): ''' Entry function. ''' parser = make_parser() args = parser.parse_args(arg_strings) if args.docker_build: return docker_build.build_with_docker(args.output_folder, sys.argv) # Checking conda-build existence if --docker_build is not specified utils.check_if_conda_build_exists() # Here, importing BuildTree is intentionally done after checking # existence of conda-build as BuildTree uses conda_build APIs. from build_tree import BuildTree # pylint: disable=import-outside-toplevel result = 0 common_package_build_args = [] common_package_build_args += [ "--output_folder", os.path.abspath(args.output_folder) ] common_package_build_args += [ "--channel", os.path.abspath(args.output_folder) ] common_package_build_args += [ "--conda_build_config", os.path.abspath(args.conda_build_config) ] for channel in args.channels_list: common_package_build_args += ["--channels", channel] # If repository_folder doesn't exist, create it if args.repository_folder and not os.path.exists(args.repository_folder): os.mkdir(args.repository_folder) # Create the build tree try: build_tree = BuildTree( env_config_files=args.env_config_file, python_versions=utils.parse_arg_list(args.python_versions), build_types=utils.parse_arg_list(args.build_types), repository_folder=args.repository_folder, git_location=args.git_location, git_tag_for_env=args.git_tag_for_env, conda_build_config=args.conda_build_config) except OpenCEError as err: print(err.msg) return 1 # Build each package in the packages list for build_command in build_tree: build_args = common_package_build_args + build_command.feedstock_args() result = build_feedstock.build_feedstock(build_args) if result != 0: print("Unable to build recipe: " + build_command.repository) return result return result
def build_env(arg_strings=None): ''' Entry function. ''' parser = make_parser() args = parser.parse_args(arg_strings) if args.docker_build: docker_build.build_with_docker(args.output_folder, sys.argv) return # Checking conda-build existence if --docker_build is not specified utils.check_if_conda_build_exists() # Here, importing BuildTree is intentionally done after checking # existence of conda-build as BuildTree uses conda_build APIs. from build_tree import BuildTree # pylint: disable=import-outside-toplevel common_package_build_args = [] common_package_build_args += [ "--output_folder", os.path.abspath(args.output_folder) ] common_package_build_args += [ "--channel", os.path.abspath(args.output_folder) ] common_package_build_args += [ "--conda_build_config", os.path.abspath(args.conda_build_config) ] for channel in args.channels_list: common_package_build_args += ["--channels", channel] # If repository_folder doesn't exist, create it if args.repository_folder and not os.path.exists(args.repository_folder): os.mkdir(args.repository_folder) # Create the build tree build_tree = BuildTree(env_config_files=args.env_config_file, python_versions=utils.parse_arg_list( args.python_versions), build_types=utils.parse_arg_list(args.build_types), mpi_types=utils.parse_arg_list(args.mpi_types), repository_folder=args.repository_folder, git_location=args.git_location, git_tag_for_env=args.git_tag_for_env, conda_build_config=args.conda_build_config) conda_env_data = CondaEnvFileGenerator( python_versions=args.python_versions, build_types=args.build_types, mpi_types=args.mpi_types, channels=args.channels_list, output_folder=os.path.abspath(args.output_folder), ) # Build each package in the packages list for build_command in build_tree: build_args = common_package_build_args + build_command.feedstock_args() try: build_feedstock.build_feedstock(build_args) except OpenCEError as exc: raise OpenCEError(Error.BUILD_RECIPE, build_command.repository, exc.msg) from exc conda_env_data.update_conda_env_file_content(build_command, build_tree) conda_env_files = conda_env_data.write_conda_env_files() print( "Generated conda environment files from the selected build arguments:", conda_env_files) print("INFO: One can use these environment files to create a conda" \ " environment using \"conda env create -f <conda_env_file_name>.\"")
def build_env(args): '''Entry Function''' if args.docker_build: if len(args.cuda_versions.split(',')) > 1: raise OpenCEError(Error.TOO_MANY_CUDA) docker_build.build_with_docker(os.path.abspath(args.output_folder), args.build_types, args.cuda_versions, sys.argv) for conda_env_file in glob.glob( os.path.join(args.output_folder, "*.yaml")): utils.replace_conda_env_channels( conda_env_file, os.path.abspath( os.path.join(docker_build.HOME_PATH, utils.DEFAULT_OUTPUT_FOLDER)), os.path.abspath(args.output_folder)) return # Checking conda-build existence if --docker_build is not specified utils.check_if_conda_build_exists() # Here, importing BuildTree is intentionally done after checking # existence of conda-build as BuildTree uses conda_build APIs. from build_tree import BuildTree # pylint: disable=import-outside-toplevel # If repository_folder doesn't exist, create it if args.repository_folder and not os.path.exists(args.repository_folder): os.mkdir(args.repository_folder) variants = utils.make_variants(args.python_versions, args.build_types, args.mpi_types, args.cuda_versions) validate_config.validate_env_config(args.conda_build_config, args.env_config_file, variants, args.repository_folder) # Create the build tree build_tree = BuildTree( env_config_files=args.env_config_file, python_versions=inputs.parse_arg_list(args.python_versions), build_types=inputs.parse_arg_list(args.build_types), mpi_types=inputs.parse_arg_list(args.mpi_types), cuda_versions=inputs.parse_arg_list(args.cuda_versions), repository_folder=args.repository_folder, git_location=args.git_location, git_tag_for_env=args.git_tag_for_env, conda_build_config=args.conda_build_config, test_labels=inputs.parse_arg_list(args.test_labels)) # Generate conda environment files conda_env_files = build_tree.write_conda_env_files( channels=args.channels_list, output_folder=os.path.abspath(args.output_folder), path=os.path.abspath(args.output_folder)) print( "Generated conda environment files from the selected build arguments:", conda_env_files.values()) print("INFO: One can use these environment files to create a conda" \ " environment using \"conda env create -f <conda_env_file_name>.\"") if not args.skip_build_packages: # Build each package in the packages list for build_command in build_tree: if not _all_outputs_exist(args.output_folder, build_command.output_files): try: print("Building " + build_command.recipe) build_feedstock.build_feedstock_from_command( build_command, output_folder=os.path.abspath(args.output_folder), extra_channels=[os.path.abspath(args.output_folder)] + args.channels_list, conda_build_config=os.path.abspath( args.conda_build_config)) except OpenCEError as exc: raise OpenCEError(Error.BUILD_RECIPE, build_command.repository, exc.msg) from exc else: print("Skipping build of " + build_command.recipe + " because it already exists") if args.run_tests: _run_tests(build_tree, conda_env_files)