diff --git a/README.md b/README.md index cc88c97..19e6111 100644 --- a/README.md +++ b/README.md @@ -101,12 +101,6 @@ Parameters: Framework parameters mentioned above as well as their related setups might be ommited. - -To Launch Graph Builder for D3JS and (optional) start DEMO server for collections in `output` dir: - -```bash -cd output && python -m http.server 8000 -``` ## Usage: Graph Operations diff --git a/arelight/backend/d3js/ui_web.py b/arelight/backend/d3js/ui_web.py index 8f119fd..aefde22 100644 --- a/arelight/backend/d3js/ui_web.py +++ b/arelight/backend/d3js/ui_web.py @@ -1,534 +1,3 @@ -import json -import os -from os.path import join - -from arekit.common.utils import create_dir_if_not_exists - -ui_template = """ - - - - - - - ARElight-0.25.0 Demo [LEGACY] - - - - - - - -
-

ARElight-0.25.0 Demo [LEGACY]

-
- -
-
-
-
-
- Here is your datasets from folder -
- -
-

-
-
-
- - - Leave top x% of Vertices by their frequency in text. -
-
- - - Scale x% of thickness for edges if you need. -
-
- - - Scale x% of opacity for edges if you need from 0 to 1. -
-
- - - Only for force graph: vertex repulsion force. -
-
- - -
-
- - -
-
- - -
- Remove unnecessary links of you need. - -
-
- -
- -
- -
- - -
-
- -
-
-
-
- - - - - -""" - - -def get_web_ui(datasets_list, host_root_path, folder_name=""): - """ datasets_list: list - list of processed datasets that stored in output folder - folder_name: str - name of folder with datasets - """ - - dataset_options = [] - for dataset in datasets_list: - dataset_options.append(f'\n') - - html_content = ui_template\ - .replace("", "\n".join(dataset_options))\ - .replace("", folder_name)\ - .replace("HOST_ROOT_PATH", host_root_path) - - return html_content - - GRAPH_TYPE_RADIAL = 'radial' GRAPH_TYPE_FORCE = 'force' @@ -539,33 +8,3 @@ def iter_ui_backend_folders(keep_graph=False, keep_desc=False): yield GRAPH_TYPE_FORCE if keep_desc: yield "descriptions" - - -def save_demo_page(target_dir, host_root_path, collection_name=None, desc_name=None, desc_labels=None): - - descriptions_dir = join(target_dir, next(iter_ui_backend_folders(keep_desc=True))) - create_dir_if_not_exists(filepath=join(descriptions_dir, "__placeholder__")) - - # Add new collection and expand with existed. - suffix = '.json' - descriptors = [filename[:-len(suffix)] for filename in os.listdir(descriptions_dir) - if filename.endswith(suffix)] - - # Save Graph description. - if collection_name is not None: - desc_path = join(descriptions_dir, f"{collection_name}{suffix}") - with open(desc_path, "w") as f: - f.write(json.dumps({ - "description": desc_name if descriptors is not None else collection_name, - "labels": desc_labels - })) - - # Place collection name on to of the list. - if collection_name in descriptors: - del descriptors[descriptors.index(collection_name)] - descriptors = [collection_name] + descriptors - - # Demo content. - html_content = get_web_ui(datasets_list=descriptors, host_root_path=host_root_path) - with open(join(target_dir, "index.html"), "w") as f_out: - f_out.write(html_content) diff --git a/arelight/pipelines/items/backend_d3js_operations.py b/arelight/pipelines/items/backend_d3js_operations.py index eecbb63..e94077e 100644 --- a/arelight/pipelines/items/backend_d3js_operations.py +++ b/arelight/pipelines/items/backend_d3js_operations.py @@ -7,7 +7,7 @@ from arekit.common.pipeline.items.base import BasePipelineItem from arelight.backend.d3js.relations_graph_operations import graphs_operations -from arelight.backend.d3js.ui_web import save_demo_page, iter_ui_backend_folders, GRAPH_TYPE_RADIAL +from arelight.backend.d3js.ui_web import iter_ui_backend_folders, GRAPH_TYPE_RADIAL from arelight.backend.d3js.utils_graph import save_graph @@ -30,7 +30,6 @@ def apply_core(self, input_data, pipeline_ctx): target_dir = pipeline_ctx.provide("d3js_graph_output_dir") collection_name = pipeline_ctx.provide("d3js_collection_name") labels_fmt = pipeline_ctx.provide("labels_formatter") - host_port = pipeline_ctx.provide_or_none("d3js_host") assert(isinstance(labels_fmt, StringLabelsFormatter)) graph = graphs_operations(graph_A=graph_a, graph_B=graph_b, operation=op, weights=weights) \ @@ -44,19 +43,7 @@ def apply_core(self, input_data, pipeline_ctx): out_filename=f"{collection_name}", convert_to_radial=True if graph_type == GRAPH_TYPE_RADIAL else False) - # Save Graph description. - save_demo_page(target_dir=target_dir, - collection_name=collection_name, - host_root_path=f"http://localhost:{host_port}/" if host_port is not None else "./", - desc_name=pipeline_ctx.provide_or_none("d3js_collection_description"), - desc_labels={label_type.__name__: labels_fmt.label_to_str(label_type()) - for label_type in labels_fmt._stol.values()}) logger.info(f"\n") logger.info(f"Dataset is completed and saved in the following locations:") for subfolder in iter_ui_backend_folders(keep_desc=True, keep_graph=True): logger.info(f"- {os.path.join(target_dir, subfolder, collection_name)}") - - # Print system info. - if host_port is not None: - cmd = f"cd {target_dir} && python -m http.server {host_port}" - logger.info(f"To host, launch manually: {cmd}") diff --git a/arelight/run/infer.py b/arelight/run/infer.py index 0a6c95c..0061d29 100644 --- a/arelight/run/infer.py +++ b/arelight/run/infer.py @@ -76,7 +76,6 @@ def create_infer_parser(): parser.add_argument("--device-type", dest="device_type", type=str, default="cpu", help="Device type applicable for launching machine learning models") parser.add_argument("--backend", dest="backend", type=str, default=None, choices=[None, "d3js_graphs"]) parser.add_argument("--label-names", dest="d3js_label_names", type=str, default="p:pos,n:neg,u:neu") - parser.add_argument("--host", dest="d3js_host", default=None, type=str) parser.add_argument('--log-file', dest="log_file", default=None, type=str) parser.add_argument('-o', dest='output_template', type=str, default="output", nargs='?') @@ -106,8 +105,6 @@ def create_infer_parser(): output_template = args.output_template output_dir = dirname(args.output_template) if dirname(args.output_template) != "" else args.output_template - assert(is_port_number(number=args.d3js_host, is_optional=True)) - # Classification task label scaler setup. labels_scl = {a: int(v) for a, v in map(lambda itm: itm.split(":"), args.labels_fmt.split(','))} labels_scaler = CustomLabelScaler(**labels_scl) @@ -318,8 +315,7 @@ def __entity_display_value(entity_value): "labels_formatter": CustomLabelsFormatter(**labels_fmt), "d3js_collection_name": collection_name, "d3js_collection_description": collection_name, - "d3js_graph_output_dir": output_dir, - "d3js_host": args.d3js_host, + "d3js_graph_output_dir": output_dir }) settings.append({ diff --git a/arelight/run/operations.py b/arelight/run/operations.py index de67869..077901d 100644 --- a/arelight/run/operations.py +++ b/arelight/run/operations.py @@ -141,7 +141,6 @@ def create_operations_parser(op_list): "labels_formatter": CustomLabelsFormatter(**labels_fmt), "d3js_graph_output_dir": output_dir, "d3js_collection_description": description, - "d3js_host": str(8000) if do_host else None, "d3js_graph_a": load_graph(graph_A_file_path), "d3js_graph_b": load_graph(graph_B_file_path), "d3js_graph_operations": operation, diff --git a/test/test_arekit_iter_data.py b/test/test_arekit_iter_data.py index cd3c4ec..bba2e80 100644 --- a/test/test_arekit_iter_data.py +++ b/test/test_arekit_iter_data.py @@ -49,7 +49,6 @@ def test_pipeline_item(self): "labels_scaler": CustomLabelScaler(), "labels_formatter": CustomLabelsFormatter(), "d3js_graph_output_dir": utils.TEST_OUT_DIR, - "d3js_host": None, "predict_reader": PandasCsvReader(compression='infer') }) ppl_result.update("samples_io", samples_io)