Skip to content

Commit

Permalink
Remove pdftopng and update Github CI
Browse files Browse the repository at this point in the history
  • Loading branch information
julianbelina committed Feb 21, 2024
2 parents 70bede3 + 21dde6b commit 2405ae7
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 902 deletions.
44 changes: 26 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
name: Run ETHOS.PeNALPS Tests
on:
push:
branches: main
pull_request:
branches: main
# Allows to trigger the workflow manually
workflow_dispatch:
branches: main
schedule:
# * is a special character in YAML so you have to quote this string
# Some Examples for cron syntax https://crontab.guru/examples.html
# Schedules job at any point after 12 pm
- cron: '0 0 * * *'
# Weekly after sunday
# - cron: 0 0 * * 0

on:
workflow_dispatch:
inputs:
tags:
description: 'Manual run'
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
# Allows to trigger the workflow manually

schedule:
# * is a special character in YAML so you have to quote this string
# Some Examples for cron syntax https://crontab.guru/examples.html
# Schedules job at any point after 12 pm
- cron: '0 0 * * *'
# Weekly after sunday
# - cron: 0 0 * * 0


jobs:
TestGeokitCondaForge:
TestPeNALPSCondaForge:
name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -47,7 +55,7 @@ jobs:
conda run -n test_env pytest
echo "Pytest done"
TestGeokitDevLocal:
TestPeNALPSDevLocal:
name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
Expand Down
13 changes: 13 additions & 0 deletions asd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pdf2image import convert_from_path

import tempfile

path_to_pdf = r"C:\Programming\ethos_penalps\examples\basic_examples.py\report_2024_02_21__11_43_50\tex_folder\enterprise_text_file.pdf"

path_to_png = path_to_pdf[:-4] + ".png"
with tempfile.TemporaryDirectory() as path:
list_of_pillow_images = convert_from_path(path_to_pdf)

for image in list_of_pillow_images:
converted_image = image.convert("RGBA")
converted_image.save(path_to_png)
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ dependencies:
- conda-forge::tectonic
- conda-forge::typeguard
- conda-forge::dataclasses-json
- conda-forge::pdftopng
- conda-forge::jsonpickle
- conda-forge::pdf2image
369 changes: 0 additions & 369 deletions ethos

This file was deleted.

473 changes: 0 additions & 473 deletions ittsc_lpg

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "ethos_penalps"
version = "1.0.1"
version = "1.0.2"
description = "A package to create energy load curves for industry locations in Germany"
readme = "README.md"
authors = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import os
import subprocess
import tempfile
import uuid
import webbrowser
from dataclasses import dataclass, field

import numpy
import pandas
from pdf2image import convert_from_path
from pdf2image.exceptions import (
PDFInfoNotInstalledError,
PDFPageCountError,
PDFSyntaxError,
)

from ethos_penalps.network_level import NetworkLevel
from ethos_penalps.post_processing.tikz_visualizations.tikz_wrapper import (
Expand Down Expand Up @@ -195,12 +202,12 @@ def __post_init__(self):
self.list_of_optional_sinks = []
self.list_of_optional_sources = []
self.dictionary_of_tikz_process_node_names: dict[str, str] = {}
self.dictionary_of_tikz_process_node_names[
self.main_sink.name
] = self.unique_sink_name
self.dictionary_of_tikz_process_node_names[
self.main_source.name
] = self.unique_source_name
self.dictionary_of_tikz_process_node_names[self.main_sink.name] = (
self.unique_sink_name
)
self.dictionary_of_tikz_process_node_names[self.main_source.name] = (
self.unique_source_name
)
for process_node in self.process_chain.process_node_dict.values():
if type(process_node) is ProcessStep:
self.sorted_process_step_list.append(process_node)
Expand All @@ -217,9 +224,9 @@ def __post_init__(self):
node_options="ProcessStepNode",
)
)
self.dictionary_of_tikz_process_node_names[
process_node.name
] = unique_process_node_name
self.dictionary_of_tikz_process_node_names[process_node.name] = (
unique_process_node_name
)
self.process_step_chain_length = len(self.sorted_process_step_list)


Expand Down Expand Up @@ -528,14 +535,11 @@ def compile_pdf(self) -> str:

def convert_pdf_to_png(self, path_to_pdf: str) -> str:
path_to_png = path_to_pdf[:-4] + ".png"
subprocess.run(
[
"pdftopng",
path_to_pdf,
path_to_png,
],
check=True,
)
with tempfile.TemporaryDirectory() as path:
list_of_pillow_images = convert_from_path(path_to_pdf)
for image in list_of_pillow_images:
converted_image = image.convert("RGBA")
converted_image.save(path_to_png)
return path_to_png

def create_enterprise_graph(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os
import subprocess
import tempfile
import uuid
import webbrowser
from dataclasses import dataclass, field

import pandas
from pdf2image import convert_from_path

from ethos_penalps.process_nodes.process_node import ProcessNode
from ethos_penalps.process_nodes.process_step import ProcessStep
Expand Down Expand Up @@ -212,9 +214,9 @@ class PathPortPair:

@dataclass
class EdgePath:
list_of_edge_node_pairs: list[
ForwardEdge | BackwardEdge | IntermediateEdge
] = field(default_factory=list)
list_of_edge_node_pairs: list[ForwardEdge | BackwardEdge | IntermediateEdge] = (
field(default_factory=list)
)


@dataclass
Expand Down Expand Up @@ -480,9 +482,9 @@ def add_junction(self, path_junction: PathJunction):
self.list_of_initial_junction_state_connectors.append(
path_junction.state_connector
)
self.dict_of_all_juctions[
path_junction.state_path_connector
] = path_junction
self.dict_of_all_juctions[path_junction.state_path_connector] = (
path_junction
)
self.list_of_remaining_junctions.append(path_junction)

def pop_path_junction(self) -> PathJunction:
Expand Down Expand Up @@ -517,9 +519,9 @@ def __init__(
display_names_dict,
) -> None:
self.state_path_handler: StatePathHandler = StatePathHandler()
self.unique_process_state_names: dict[
str, dict[str, str] | str
] = unique_process_state_names
self.unique_process_state_names: dict[str, dict[str, str] | str] = (
unique_process_state_names
)
self.display_names_dict: dict[str, dict[str, str] | str] = display_names_dict
self.process_state_handler: ProcessStateHandler = process_state_handler
self.output_stream_state_name = (
Expand Down Expand Up @@ -1089,9 +1091,9 @@ def create_unique_node_names(self):
if isinstance(process_node, ProcessStep):
unique_process_node_name = process_node_name.replace(" ", "-")
unique_process_node_name = unique_process_node_name.replace("_", "-")
self.unique_process_node_name_dict[
process_node_name
] = unique_process_node_name
self.unique_process_node_name_dict[process_node_name] = (
unique_process_node_name
)
self.unique_process_state_names[process_node_name] = {}
for (
process_state_name
Expand All @@ -1106,9 +1108,9 @@ def create_unique_node_names(self):
elif isinstance(process_node, (Source, Sink)):
unique_process_node_name = process_node_name.replace(" ", "")
unique_process_node_name = unique_process_node_name.replace("_", "-")
self.unique_process_node_name_dict[
process_node_name
] = unique_process_node_name
self.unique_process_node_name_dict[process_node_name] = (
unique_process_node_name
)

def create_display_names(self):
"""Remove whitespaces from node names"""
Expand Down Expand Up @@ -1261,14 +1263,12 @@ def compile_pdf(self) -> str:

def convert_pdf_to_png(self, path_to_pdf: str) -> str:
path_to_png = path_to_pdf[:-4] + ".png"
subprocess.run(
[
"pdftopng",
path_to_pdf,
path_to_png,
],
check=True,
)
with tempfile.TemporaryDirectory() as path:
list_of_pillow_images = convert_from_path(path_to_pdf)

for image in list_of_pillow_images:
converted_image = image.convert("RGBA")
converted_image.save(path_to_png)
return path_to_png

def create_enterprise_graph(
Expand Down

0 comments on commit 2405ae7

Please sign in to comment.