Skip to content
Snippets Groups Projects
Commit 84842b26 authored by Leštáková, Michaela's avatar Leštáková, Michaela
Browse files

Merge branch '3-packaging' into 'main'

Resolve "Packaging"

Closes #3

See merge request !5
parents 7c7ad6d7 787f22b1
No related branches found
No related tags found
1 merge request!5Resolve "Packaging"
Pipeline #1053256 passed
...@@ -10,3 +10,4 @@ ...@@ -10,3 +10,4 @@
!doc/ !doc/
!make.bat !make.bat
!Makefile !Makefile
!pyproject.toml
\ No newline at end of file
...@@ -48,3 +48,25 @@ lint: ...@@ -48,3 +48,25 @@ lint:
doc: doc:
script: script:
- make html - make html
build_and_upload:
# stage: package
script:
- pip install build twine
- python3 -m build
- TWINE_PASSWORD=${CI_PYPI_TOKEN} TWINE_USERNAME=__token__ python3 -m twine upload --repository testpypi dist/*
rules:
- if: $CI_COMMIT_TAG
release_job:
# stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created
before_script:
- echo "No before script pls"
script:
- echo "running release_job"
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: "$CI_COMMIT_TAG"
description: "$CI_COMMIT_TAG"
"""Framework for serializing plots."""
__author__ = "Michaela Lestakova"
__email__ = "michaela.lestakova@fst.tu-darmstadt.de"
__version__ = "0.1.0"
...@@ -5,6 +5,7 @@ class Plot: ...@@ -5,6 +5,7 @@ class Plot:
self._axes = None self._axes = None
self._title = None self._title = None
self._caption = None self._caption = None
self._dataset = None
pass pass
@property @property
...@@ -80,3 +81,10 @@ class PlottedElement: ...@@ -80,3 +81,10 @@ class PlottedElement:
if type(label) is not str: if type(label) is not str:
raise TypeError("label must be a string.") raise TypeError("label must be a string.")
self._label = label self._label = label
class Dataset:
def __init__(self) -> None:
self._URL = None
self._file_name = None
pass
...@@ -6,9 +6,10 @@ from plot_serializer.adapters import Plot, MatplotlibAdapter ...@@ -6,9 +6,10 @@ from plot_serializer.adapters import Plot, MatplotlibAdapter
class Serializer: class Serializer:
def __init__(self, p) -> None: def __init__(self, p=None) -> None:
self._plot = None self._plot = None
self.plot = self.convert_plot(p) if p is not None:
self.load_plot(p)
pass pass
@property @property
...@@ -22,14 +23,13 @@ class Serializer: ...@@ -22,14 +23,13 @@ class Serializer:
else: else:
self._plot = plot self._plot = plot
def convert_plot(self, p) -> Plot: def load_plot(self, p) -> None:
if isinstance(p, matplotlib.pyplot.Figure): if isinstance(p, matplotlib.pyplot.Figure):
converted_plot = MatplotlibAdapter(p) self.plot = MatplotlibAdapter(p)
else: else:
raise NotImplementedError( raise NotImplementedError(
"Only matplotlib is implemented. Make sure you submit a matplotlib.pyplot.Figure object." "Only matplotlib is implemented. Make sure you submit a matplotlib.pyplot.Figure object."
) )
return converted_plot
def to_json(self, header=["id"]) -> str: def to_json(self, header=["id"]) -> str:
"""Exports plot to json. """Exports plot to json.
......
from rdflib import Graph
def unit_in_ontology(unit_name, ontology_url="default"):
if ontology_url == "default":
ontology_url = (
"https://raw.githubusercontent.com/HajoRijgersberg/OM/master/om-2.0.rdf"
)
g = Graph()
g.parse(ontology_url, format="xml")
query = (
"""
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?unit
WHERE{
?unit a om:Unit ;
rdfs:label "%s"@en .
}
"""
% unit_name
)
results = g.query(query)
return len(results)
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "plot-serializer"
dynamic = ["version"]
description = "Serializing plots."
readme = "README.md"
authors = [
{ name = "Michaela Lestakova", email = "michaela.lestakova@fst.tu-darmstadt.de" },
{ name = "Kevin Logan", email = "kevin.logan@fst.tu-darmstadt.de" }
]
keywords = ["rdm", "plot"]
license = {file = "LICENSE"}
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3 :: Only",
]
dependencies = [
"numpy",
"pandas",
"matplotlib",
]
requires-python = ">=3.9"
[project.optional-dependencies]
dev = [
"black>=22.8.0",
"isort>=5.8.0",
"pylint>=2.15.3"
]
test = [
"pytest>=7.1.2",
"pytest-cov>=3.0.0",
"mypy>=0.971",
"pandas-stubs>=1.4.3.220822",
"types-tqdm>=4.64.5",
"types-pytz>=2022.2.1.0"
]
doc = ["sphinx>=5.1.1", "sphinx-rtd-theme>=1.0.0", "sphinx-autoapi",]
[project.urls]
repository = "https://git.rwth-aachen.de/rdm-tools/plot-serializer"
documentation = "https://plot-serializer.readthedocs.io/en/latest/"
[tool.setuptools.dynamic]
version = {attr = "plot_serializer.__version__"}
[tool.setuptools.packages.find]
where = ["."]
[tool.mypy]
strict = true
show_error_codes = true
[[tool.mypy.overrides]]
module = [
"matplotlib",
"matplotlib.axes",
"matplotlib.pyplot",
"OMPython"
]
ignore_missing_imports = true
[tool.black]
line_length = 88
[tool.isort]
atomic = true
profile = "black"
line_length = 88
skip_gitignore = true
[tool.pylint.main]
fail-under = 9.9
[tool.pylint.design]
max-args = 9
max-attributes = 13
max-locals = 16
[tool.pylint.format]
max-line-length = 88
[tool.pylint."messages control"]
disable = ["attribute-defined-outside-init"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment