Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/cdci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Python package

on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
cache-dependency-path: '**/pyproject.toml'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -e .
- name: Run tests
run: python -m pytest tests

38 changes: 34 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,46 @@ Also, the class diagram for the project is presented below to illustrate the arc
</p>

## Installation
......

You can install the package for development from this repository by running the following command:

```bash
pip install -e path/to/vuegen # specify location
pip install -e . # in case you pwd is in the vuegen directory
```

### Quatro installation

Install quatro with vueguen if you don't have it globally installed.

```bash
pip install -e ".[quarto]" # specify location
```

if you use conda a conda environement you can install quatro from the conda-forge channel
in case it did not work.

```bash
conda install -c conda-forge quarto
```

Test your quarto installation by running the following command:

```bash
quarto check
```


## Execution
``` shell
python vuegen/main.py --config report_config_micw2graph.yaml --report_type streamlit

```bash
python vuegen/main.py --config example_data/MicW2Graph/report_config_micw2graph.yaml --report_type streamlit
```

The current report types are streamlit, html, pdf, docx, odt, revealjs, pptx, and jupyter.

## Contact
If you have comments or suggestions about this project, you can [open an issue][issues] in this repository.

[issues]: https://github.com/Multiomics-Analytics-Group/vuegen/issues/new
[streamlit]: https://streamlit.io/
[streamlit]: https://streamlit.io/
26 changes: 13 additions & 13 deletions example_data/MicW2Graph/report_config_micw2graph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ report:
infer potential interactions among microorganisms through microbial association networks (MANs). MicW2Graph enables the
investigation of research questions related to WWT, focusing on aspects such as microbial connections, community memberships,
and potential ecological functions.
graphical_abstract: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/Methods_MicW2Graph.png
logo: /Users/asaru/Documents/DTU/MoNA/vuegen/docs/images/vuegen_logo.png
graphical_abstract: example_data/MicW2Graph/Methods_MicW2Graph.png
logo: docs/images/vuegen_logo.png
sections:
- title: Exploratory Data Analysis
subsections:
Expand All @@ -25,34 +25,34 @@ sections:
- title: Multiline plot (altair)
component_type: plot
plot_type: altair
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/1_Exploratory_Data_Analysis/1_Abundance_data/2_multilineplot_altair.json
file_path: example_data/MicW2Graph/1_Exploratory_Data_Analysis/1_Abundance_data/2_multilineplot_altair.json
- title: Abundance data for all studies (csv)
component_type: dataframe
file_path: https://raw.githubusercontent.com/sayalaruano/report_generator_st_cloud_test/main/example_data/MicW2Graph/abundance_data_allbiomes.csv
file_format: csv
delimiter: ','
- title: Abundance data for all studies (xls)
component_type: dataframe
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/1_Exploratory_Data_Analysis/1_Abundance_data/4_abundance_data_allbiomes.xls
file_path: example_data/MicW2Graph/1_Exploratory_Data_Analysis/1_Abundance_data/4_abundance_data_allbiomes.xls
file_format: xls
delimiter: ','
- title: Sample data
components:
- title: Number of samples per study (png)
component_type: plot
plot_type: static
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/1_Exploratory_Data_Analysis/2_Sample_data/3_number_samples_per_study.png
file_path: example_data/MicW2Graph/1_Exploratory_Data_Analysis/2_Sample_data/3_number_samples_per_study.png
- title: Sampling countries for all studies (plotly)
component_type: plot
plot_type: plotly
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/1_Exploratory_Data_Analysis/2_Sample_data/1_pie_plot_countries_plotly.json
file_path: example_data/MicW2Graph/1_Exploratory_Data_Analysis/2_Sample_data/1_pie_plot_countries_plotly.json
- title: Sample data for all studies (parquet)
component_type: dataframe
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/1_Exploratory_Data_Analysis/2_Sample_data/4_sample_info_allbiomes.parquet
file_path: example_data/MicW2Graph/1_Exploratory_Data_Analysis/2_Sample_data/4_sample_info_allbiomes.parquet
file_format: parquet
- title: Sample data for all studies (txt)
component_type: dataframe
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/1_Exploratory_Data_Analysis/2_Sample_data/5_sample_info_allbiomes.txt
file_path: example_data/MicW2Graph/1_Exploratory_Data_Analysis/2_Sample_data/5_sample_info_allbiomes.txt
file_format: txt
- title: Extra information
components:
Expand All @@ -66,17 +66,17 @@ sections:
- title: Network1 (graphml)
component_type: plot
plot_type: interactive_network
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/2_Microbial_Association_Networks/1_Network_visualization1/1_man_example.graphml
file_path: example_data/MicW2Graph/2_Microbial_Association_Networks/1_Network_visualization1/1_man_example.graphml
- title: Network Visualization2
components:
- title: Network2 (edge list csv)
component_type: plot
plot_type: interactive_network
csv_network_format: edgelist
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/2_Microbial_Association_Networks/2_Network_visualization2/1_man_example.csv
file_path: example_data/MicW2Graph/2_Microbial_Association_Networks/2_Network_visualization2/1_man_example.csv
- title: Edge list (csv)
component_type: dataframe
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/2_Microbial_Association_Networks/2_Network_visualization2/1_man_example.csv
file_path: example_data/MicW2Graph/2_Microbial_Association_Networks/2_Network_visualization2/1_man_example.csv
file_format: csv
delimiter: ','
caption: This is the edge list of the network
Expand All @@ -85,13 +85,13 @@ sections:
- title: Network3 (cyjs)
component_type: plot
plot_type: interactive_network
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/2_Microbial_Association_Networks/3_Network_visualization3/1_man_example.cyjs
file_path: example_data/MicW2Graph/2_Microbial_Association_Networks/3_Network_visualization3/1_man_example.cyjs
- title: Network Visualization4
components:
- title: Network4 (html)
component_type: plot
plot_type: interactive_network
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/2_Microbial_Association_Networks/4_Network_visualization4/1_ckg_network.html
file_path: example_data/MicW2Graph/2_Microbial_Association_Networks/4_Network_visualization4/1_ckg_network.html
- title: Network Visualization5
components:
- title: Network5 (remote html)
Expand Down
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[tool.poetry]
name = "report-generator"
name = "vuegen"
version = "0.1.0"
description = "Module to generate automatic web interface reports with visualizations"
authors = ["MoNA group"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/Multiomics-Analytics-Group/vuegen"

[tool.poetry.dependencies]
python = ">=3.9,<3.9.7 || >3.9.7,<4.0"
Expand All @@ -25,11 +26,20 @@ itables = "^2.2.2"
kaleido = "0.2.0"
vl-convert-python = "^1.7.0"
dataframe-image = "^0.2.6"

strenum = { version = "^0.4.15", python = "<3.11" }

[tool.poetry.group.dev.dependencies]
ipykernel = "^6.29.5"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

# https://stackoverflow.com/a/60990574/9684872
[tool.poetry.extras]
streamlit = ["streamlit"]
quarto = ["quarto", "ipykernel"]

# [project.scripts]
# my-script = "vuegen.main:main"
12 changes: 12 additions & 0 deletions tests/test_module_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

def test_imports():
import vuegen
import vuegen.main
import vuegen.quarto_reportview
import vuegen.report
import vuegen.report_generator
import vuegen.streamlit_reportview
import vuegen.utils

assert vuegen.__version__

3 changes: 3 additions & 0 deletions vuegen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from importlib.metadata import version

__version__ = version("vuegen")
7 changes: 4 additions & 3 deletions vuegen/config_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import report as r
from utils import get_logger, assert_enum_value
from . import report as r
from .utils import assert_enum_value, get_logger


class ConfigManager:
"""
Expand Down Expand Up @@ -260,4 +261,4 @@ def _create_chatbot_component(self, component_data: dict) -> r.ChatBot:
caption = component_data.get('caption'),
headers = component_data.get('headers'),
params = component_data.get('params')
)
)
4 changes: 2 additions & 2 deletions vuegen/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import report_generator
from utils import get_logger, load_yaml_config, get_args
from vuegen import report_generator
from vuegen.utils import get_args, get_logger, load_yaml_config

if __name__ == '__main__':
# Parse command-line arguments
Expand Down
10 changes: 8 additions & 2 deletions vuegen/quarto_reportview.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
import subprocess
import report as r
from typing import List

import networkx as nx
import pandas as pd
from utils import create_folder, is_url

from . import report as r
from .utils import create_folder, is_url


class QuartoReportView(r.ReportView):
"""
Expand Down Expand Up @@ -117,6 +120,9 @@ def run_report(self, output_dir: str = BASE_DIR) -> None:
except subprocess.CalledProcessError as e:
self.report.logger.error(f"Error running '{self.report.title}' {self.report_type} report: {str(e)}")
raise
except FileNotFoundError as e:
self.report.logger.error(f"Quarto is not installed. Please install Quarto to run the report: {str(e)}")
raise

def _create_yaml_header(self) -> str:
"""
Expand Down
24 changes: 16 additions & 8 deletions vuegen/report.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import json
import logging
import os
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import ClassVar
from enum import StrEnum, auto
from typing import List, Optional
from enum import auto

try:
from enum import StrEnum
except ImportError:
from strenum import StrEnum

from typing import ClassVar, List, Optional

import matplotlib.pyplot as plt
import networkx as nx
import pandas as pd
import logging
import requests
import json
import matplotlib.pyplot as plt
from pyvis.network import Network
from utils import cyjs_to_networkx, pyvishtml_to_networkx, fetch_file_stream

from .utils import cyjs_to_networkx, fetch_file_stream, pyvishtml_to_networkx


class ReportType(StrEnum):
STREAMLIT = auto()
Expand Down Expand Up @@ -736,4 +744,4 @@ def _generate_subsection(self, subsection: Subsection) -> tuple[List[str], List[
- list of subsection content lines (List[str])
- list of imports for the subsection (List[str])
"""
pass
pass
14 changes: 8 additions & 6 deletions vuegen/report_generator.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from streamlit_reportview import StreamlitReportView
from quarto_reportview import QuartoReportView
from config_manager import ConfigManager
from utils import assert_enum_value
from report import ReportType
import logging

from .config_manager import ConfigManager
from .quarto_reportview import QuartoReportView
from .report import ReportType
from .streamlit_reportview import StreamlitReportView
from .utils import assert_enum_value


def get_report(config: dict, report_type: str, logger: logging.Logger) -> None:
"""
Generate and run a report based on the specified engine.
Expand Down Expand Up @@ -45,4 +47,4 @@ def get_report(config: dict, report_type: str, logger: logging.Logger) -> None:
report_type=report_type
)
quarto_report.generate_report()
quarto_report.run_report()
quarto_report.run_report()
9 changes: 6 additions & 3 deletions vuegen/streamlit_reportview.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import report as r
import os
import subprocess
from typing import List

import pandas as pd
from utils import create_folder, is_url

from . import report as r
from .utils import create_folder, is_url


class StreamlitReportView(r.WebAppReportView):
"""
Expand Down Expand Up @@ -658,4 +661,4 @@ def _generate_component_imports(self, component: r.Component) -> List[str]:
component_imports.extend(components_imports['chatbot'])

# Return the list of import statements
return component_imports
return component_imports
Loading
Loading