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
2 changes: 1 addition & 1 deletion .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ on:

jobs:
codeql:
uses: pyiron/actions/.github/workflows/tests-and-coverage.yml@actions-3.3.3
uses: pyiron/actions/.github/workflows/tests-and-coverage.yml@actions-4.0.1
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ on:

jobs:
pyiron:
uses: pyiron/actions/.github/workflows/dependabot-pr.yml@actions-3.3.3
uses: pyiron/actions/.github/workflows/dependabot-pr.yml@actions-4.0.1
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/pr-labeled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ on:

jobs:
pyiron:
uses: pyiron/actions/.github/workflows/pr-labeled.yml@actions-3.3.3
uses: pyiron/actions/.github/workflows/pr-labeled.yml@actions-4.0.1
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/pr-target-opened.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ on:

jobs:
pyiron:
uses: pyiron/actions/.github/workflows/pr-target-opened.yml@actions-3.3.3
uses: pyiron/actions/.github/workflows/pr-target-opened.yml@actions-4.0.1
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/preview-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
pyiron:
uses: pyiron/actions/.github/workflows/pyproject-release.yml@actions-3.3.3
uses: pyiron/actions/.github/workflows/pyproject-release.yml@actions-4.0.1
secrets: inherit
with:
runner: 'ubuntu-22.04' # with ubuntu > 22.04, pip is broken
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
pyiron:
uses: pyiron/actions/.github/workflows/push-pull.yml@actions-3.3.3
uses: pyiron/actions/.github/workflows/push-pull.yml@actions-4.0.1
with:
runner: 'ubuntu-22.04' # with ubuntu > 22.04, pip is broken
python-version-alt3: 'exclude' # No python 3.9
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ on:

jobs:
codeql:
uses: pyiron/actions/.github/workflows/codeql.yml@actions-3.3.3
uses: pyiron/actions/.github/workflows/codeql.yml@actions-4.0.1
secrets: inherit
12 changes: 7 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import importlib.util
import os
import shutil
import subprocess

from sphinx.ext.apidoc import main

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -147,12 +148,13 @@
# raise ImportError("You need to install bootstrap: pip install sphinx_bootstrap_theme")
# html_theme = 'default'

try:
import sphinx_rtd_theme

if importlib.util.find_spec("sphinx_rtd_theme") is not None:
# sphinx_rtd_theme is available
html_theme = "sphinx_rtd_theme"
except ImportError:
html_theme = "default"
else:
# fallback theme
html_theme = "alabaster"


# Theme options are theme-specific and customize the look and feel of a theme
Expand Down
4 changes: 2 additions & 2 deletions notebooks/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"source": [
"from pint import UnitRegistry\n",
"\n",
"from semantikon.typing import u\n",
"from semantikon.converter import units"
"from semantikon.converter import units\n",
"from semantikon.typing import u"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion semantikon/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"""Git implementation of _version.py."""

import errno
import functools
import os
import re
import subprocess
import sys
from typing import Any, Callable, Dict, List, Optional, Tuple
import functools


def get_keywords() -> Dict[str, str]:
Expand Down
9 changes: 5 additions & 4 deletions semantikon/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.

from pint import Quantity
import inspect
import sys
from functools import wraps
from typing import get_args, get_origin, get_type_hints

from pint import Quantity
from pint.registry_helpers import (
_apply_defaults,
_parse_wrap_args,
_to_units_container,
_replace_units,
_to_units_container,
)
from typing import get_origin, get_args, get_type_hints
import sys

__author__ = "Sam Waseda"
__copyright__ = (
Expand Down
13 changes: 7 additions & 6 deletions semantikon/ontology.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from typing import TypeAlias, Any
import warnings

from rdflib import Graph, Literal, RDF, RDFS, URIRef, OWL, PROV, Namespace, BNode, SH
from dataclasses import is_dataclass
from semantikon.converter import meta_to_dict, get_function_dict
from semantikon.qudt import UnitsDict
from typing import Any, TypeAlias

from owlrl import DeductiveClosure, OWLRL_Semantics
from rdflib import OWL, PROV, RDF, RDFS, SH, BNode, Graph, Literal, Namespace, URIRef

from semantikon.converter import get_function_dict, meta_to_dict
from semantikon.qudt import UnitsDict


class SNS:
Expand Down Expand Up @@ -267,7 +268,7 @@ def _validate_values_by_python(graph: Graph) -> list:
if on_property and some_values_from:
for cls in graph.subjects(OWL.equivalentClass, restrictions):
for instance in graph.subjects(RDF.type, cls):
if not (instance, on_property, some_values_from) in graph:
if (instance, on_property, some_values_from) not in graph:
missing_triples.append(
(instance, on_property, some_values_from)
)
Expand Down
7 changes: 3 additions & 4 deletions semantikon/qudt.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
from rdflib import Graph, RDFS, URIRef
from pint import UnitRegistry
from pint.errors import UndefinedUnitError, OffsetUnitCalculusError, DimensionalityError
from tokenize import TokenError

import requests
from pint import UnitRegistry
from rdflib import RDFS, Graph, URIRef


def _is_english_label(pred, obj):
Expand Down
1 change: 1 addition & 0 deletions semantikon/typing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Annotated, get_origin

from semantikon.converter import parse_metadata

__author__ = "Sam Waseda"
Expand Down
5 changes: 3 additions & 2 deletions semantikon/visualize.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from rdflib import RDF, URIRef, Literal, BNode
from graphviz import Digraph
from string import Template

from graphviz import Digraph
from rdflib import RDF, BNode, Literal, URIRef

from semantikon.ontology import SNS


Expand Down
9 changes: 5 additions & 4 deletions semantikon/workflow.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import ast
import networkx as nx
from networkx.algorithms.dag import topological_sort
import copy
import inspect
import warnings
from collections import deque
from functools import cached_property
import warnings
from hashlib import sha256
import copy

import networkx as nx
from networkx.algorithms.dag import topological_sort

from semantikon.converter import parse_input_args, parse_output_args

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from setuptools import setup

import versioneer
from setuptools import setup

setup(
version=versioneer.get_version(),
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/test_dataclass.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import unittest
from semantikon.typing import u
from typing import Annotated
from dataclasses import dataclass
from semantikon.converter import semantikon_class, parse_metadata
from typing import Annotated

from semantikon.converter import parse_metadata, semantikon_class
from semantikon.typing import u


@semantikon_class
Expand Down
30 changes: 11 additions & 19 deletions tests/unit/test_ontology.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import unittest
from dataclasses import dataclass
from textwrap import dedent
from rdflib import Graph, OWL, Namespace, URIRef, Literal, RDF, RDFS, SH, PROV
from owlrl import DeductiveClosure, OWLRL_Semantics
from pyshacl import validate

from graphviz import Digraph
from semantikon.typing import u
from semantikon.converter import (
parse_input_args,
parse_output_args,
parse_metadata,
get_function_dict,
)
from pyshacl import validate
from rdflib import OWL, PROV, RDF, RDFS, SH, Literal, Namespace, URIRef

from semantikon.ontology import (
get_knowledge_graph,
NS,
SNS,
_inherit_properties,
validate_values,
_parse_cancel,
dataclass_to_knowledge_graph,
get_knowledge_graph,
serialize_data,
_parse_cancel,
NS,
validate_values,
)
from semantikon.workflow import workflow, separate_types, separate_functions
from semantikon.typing import u
from semantikon.visualize import visualize
from dataclasses import dataclass

from semantikon.workflow import workflow

EX = Namespace("http://example.org/")

Expand Down Expand Up @@ -537,7 +530,6 @@ def test_dataclass(self):
(URIRef(f"{i_txt}.parameters.a.value"), RDF.value, Literal(2)),
(URIRef(o_txt), SNS.hasValue, URIRef(f"{o_txt}.E.value")),
)
s = graph.serialize(format="turtle")
for ii, triple in enumerate(triples):
with self.subTest(i=ii):
self.assertEqual(
Expand Down
15 changes: 12 additions & 3 deletions tests/unit/test_parsers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import unittest
from semantikon.typing import u
from typing import TYPE_CHECKING

from semantikon.converter import (
get_function_dict,
parse_input_args,
parse_output_args,
parse_metadata,
get_function_dict,
parse_output_args,
)
from semantikon.typing import u

if TYPE_CHECKING:

class Atoms:
pass


class TestParser(unittest.TestCase):
Expand Down Expand Up @@ -114,13 +121,15 @@ def get_speed_multiple_args(
return distance / time
else:
return distance / duration

input_args = parse_input_args(get_speed_multiple_args)
for value, key in zip(input_args.values(), ["meter", "second", "second"]):
self.assertEqual(value["units"], key)

def test_future(self):
def test_another_future(x: "Atoms", y: "u(float, units='second')") -> "Atoms":
return x

input_args = parse_input_args(test_another_future)
self.assertEqual(input_args["x"]["dtype"], "Atoms")
self.assertIn("units", input_args["y"])
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_qudt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

from semantikon.qudt import UnitsDict


Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import semantikon


Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_units.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import unittest
from semantikon.typing import u
from semantikon.converter import units

from pint import UnitRegistry

from semantikon.converter import units
from semantikon.typing import u


@units
def get_speed_multiple_outputs(
Expand Down
13 changes: 6 additions & 7 deletions tests/unit/test_workflow.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import unittest

from semantikon.typing import u
from semantikon.workflow import (
analyze_function,
get_return_variables,
_get_output_counts,
get_workflow_dict,
workflow,
analyze_function,
find_parallel_execution_levels,
get_node_dict,
separate_types,
get_return_variables,
get_workflow_dict,
separate_functions,
separate_types,
workflow,
)
import numpy as np
import json


def operation(x: float, y: float) -> tuple[float, float]:
Expand Down
Loading