def make_html_map(state: DatasetExportState, base_path: Path) -> dict: html_map = { "css_style": Util.get_css_content(DatasetExportHTMLBuilder.CSS_PATH), "name": state.name, 'immuneML_version': MLUtil.get_immuneML_version(), "full_specs": Util.get_full_specs_path(base_path), "datasets": [{ "dataset_name": dataset.name, "dataset_type": StringHelper.camel_case_to_word_string(type(dataset).__name__), "dataset_size": f"{dataset.get_example_count()} {type(dataset).__name__.replace('Dataset', 's').lower()}", "labels": [{ "label_name": label } for label in dataset.get_label_names()], "formats": [{ "format_name": format_name, "dataset_download_link": os.path.relpath(path=Util.make_downloadable_zip( state.result_path, state.paths[dataset.name][format_name]), start=base_path) } for format_name in state.formats] } for dataset in state.datasets] } return html_map
def make_html_map(state: DatasetExportState, base_path: Path) -> dict: html_map = { "css_style": Util.get_css_content(DatasetExportHTMLBuilder.CSS_PATH), "name": state.name, 'immuneML_version': MLUtil.get_immuneML_version(), "full_specs": Util.get_full_specs_path(base_path), "datasets": [ { "dataset_name": dataset.name, "dataset_type": StringHelper.camel_case_to_word_string(type(dataset).__name__), "dataset_size": f"{dataset.get_example_count()} {type(dataset).__name__.replace('Dataset', 's').lower()}", "labels": [{"label_name": label} for label in dataset.get_label_names()], "preprocessing_sequence": [ { "preprocessing_name": preprocessing.__class__.__name__, "preprocessing_params": ", ".join([f"{key}: {value}" for key, value in vars(preprocessing).items()]) } for preprocessing in state.preprocessing_sequence ] if state.preprocessing_sequence is not None else [], "show_preprocessing": state.preprocessing_sequence is not None and len(state.preprocessing_sequence) > 0, "formats": [ { "format_name": format_name, "dataset_download_link": os.path.relpath(path=Util.make_downloadable_zip(state.result_path, state.paths[dataset.name][format_name]), start=base_path) } for format_name in state.formats ] } for dataset in state.datasets ] } return html_map
def make_html_map(state: ExploratoryAnalysisState, base_path: Path) -> dict: html_map = { "css_style": Util.get_css_content(ExploratoryAnalysisHTMLBuilder.CSS_PATH), "full_specs": Util.get_full_specs_path(base_path), 'immuneML_version': MLUtil.get_immuneML_version(), "analyses": [{ "name": name, "dataset_name": analysis.dataset.name if analysis.dataset.name is not None else analysis.dataset.identifier, "dataset_type": StringHelper.camel_case_to_word_string( type(analysis.dataset).__name__), "example_count": analysis.dataset.get_example_count(), "dataset_size": f"{analysis.dataset.get_example_count()} {type(analysis.dataset).__name__.replace('Dataset', 's').lower()}", "show_labels": analysis.label_config is not None and len(analysis.label_config.get_labels_by_name()) > 0, "labels": [{ "name": label.name, "values": str(label.values)[1:-1] } for label in analysis.label_config.get_label_objects()] if analysis.label_config else None, "encoding_key": analysis.encoder.name if analysis.encoder is not None else None, "encoding_name": StringHelper.camel_case_to_word_string( type(analysis.encoder).__name__) if analysis.encoder is not None else None, "encoding_params": [{ "param_name": key, "param_value": value } for key, value in vars(analysis.encoder).items()] if analysis.encoder is not None else None, "show_encoding": analysis.encoder is not None, "report": Util.to_dict_recursive(analysis.report_result, base_path) } for name, analysis in state.exploratory_analysis_units.items()] } for analysis in html_map["analyses"]: analysis["show_tables"] = len( analysis["report"]["output_tables"] ) > 0 if "output_tables" in analysis["report"] else False analysis["show_text"] = len( analysis["report"]["output_text"] ) > 0 if "output_text" in analysis["report"] else False return html_map
def _make_document(presentations: List[InstructionPresentation], path: Path) -> Path: result_path = path / "index.html" if len(presentations) > 1: html_map = {"instructions": presentations, "css_path": EnvironmentSettings.html_templates_path / "css/custom.css", "full_specs": Util.get_full_specs_path(path), 'immuneML_version': MLUtil.get_immuneML_version()} TemplateParser.parse(template_path=EnvironmentSettings.html_templates_path / "index.html", template_map=html_map, result_path=result_path) elif len(presentations) == 1: shutil.copyfile(str(presentations[0].path), str(result_path)) HTMLBuilder._update_paths(result_path) else: result_path = None return result_path
def _make_main_html_map(state: TrainMLModelState, base_path: Path) -> dict: html_map = { "css_style": Util.get_css_content(HPHTMLBuilder.CSS_PATH), "full_specs": Util.get_full_specs_path(base_path), "dataset_name": state.dataset.name if state.dataset.name is not None else state.dataset.identifier, "dataset_type": StringHelper.camel_case_to_word_string( type(state.dataset).__name__), "example_count": state.dataset.get_example_count(), "dataset_size": f"{state.dataset.get_example_count()} {type(state.dataset).__name__.replace('Dataset', 's').lower()}", "labels": [{ "name": label.name, "values": str(label.values)[1:-1] } for label in state.label_configuration.get_label_objects()], "optimization_metric": state.optimization_metric.name.lower(), "other_metrics": str([metric.name.lower() for metric in state.metrics])[1:-1].replace("'", ""), "metrics": [{ "name": metric.name.lower() } for metric in state.metrics], "assessment_desc": state.assessment, "selection_desc": state.selection, "show_hp_reports": bool(state.report_results), 'hp_reports': Util.to_dict_recursive(state.report_results, base_path) if state.report_results else None, "hp_per_label": HPHTMLBuilder._make_hp_per_label(state), 'models_per_label': HPHTMLBuilder._make_model_per_label(state, base_path), 'immuneML_version': MLUtil.get_immuneML_version() } return html_map
def make_html_map(state: SimulationState, base_path: Path) -> dict: html_map = { "css_style": Util.get_css_content(SimulationHTMLBuilder.CSS_PATH), "name": state.name, 'immuneML_version': MLUtil.get_immuneML_version(), "full_specs": Util.get_full_specs_path(base_path), "dataset_name": state.resulting_dataset.name if state.resulting_dataset.name is not None else state.resulting_dataset.identifier, "dataset_type": StringHelper.camel_case_to_word_string( type(state.resulting_dataset).__name__), "example_count": state.resulting_dataset.get_example_count(), "dataset_size": f"{state.resulting_dataset.get_example_count()} {type(state.resulting_dataset).__name__.replace('Dataset', 's').lower()}", "labels": [{ "label_name": label } for label in state.resulting_dataset.get_label_names()], "formats": [{ "format_name": format_name, "dataset_download_link": os.path.relpath(path=Util.make_downloadable_zip( state.result_path, state.paths[state.resulting_dataset.name][format_name]), start=base_path) } for format_name in state.formats], "implantings": [ Util.to_dict_recursive(implanting, base_path) for implanting in state.simulation.implantings ] } return html_map
def make_html_map(state: SubsamplingState, base_path: Path) -> dict: html_map = { "css_style": Util.get_css_content(SubsamplingHTMLBuilder.CSS_PATH), "name": state.name, 'immuneML_version': MLUtil.get_immuneML_version(), "full_specs": Util.get_full_specs_path(base_path), "dataset_name": state.dataset.name if state.dataset.name is not None else state.dataset.identifier, "labels": [{ "label_name": label } for label in state.dataset.get_label_names()], "dataset_type": StringHelper.camel_case_to_word_string( type(state.dataset).__name__), "example_count": state.dataset.get_example_count(), "subsampled_datasets": [{ "sub_dataset_iter": i, "sub_dataset_name": dataset.name, "dataset_size": f"{dataset.get_example_count()} {type(dataset).__name__.replace('Dataset', 's').lower()}", "formats": [{ "dataset_download_link": item, "format_name": key } for key, item in state.subsampled_dataset_paths[ dataset.name].items()] } for i, dataset in enumerate(state.subsampled_datasets, 1)] } return html_map