mustrd 0.3.1a8__py3-none-any.whl → 0.3.1a9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mustrd/mustrdAnzo.py CHANGED
@@ -1,27 +1,3 @@
1
- """
2
- MIT License
3
-
4
- Copyright (c) 2023 Semantic Partners Ltd
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
23
- """
24
-
25
1
  from rdflib import Graph, ConjunctiveGraph, Literal, URIRef
26
2
  from requests import ConnectTimeout, HTTPError, ConnectionError
27
3
  import logging
@@ -166,6 +142,7 @@ def upload_given(triple_store: dict, given: Graph):
166
142
  insert_query = f"INSERT DATA {{graph <{triple_store['input_graph']}>{{{serialized_given}}}}}"
167
143
  query_azg(anzo_config=triple_store, query=insert_query, is_update=True)
168
144
  except (ConnectionError, TimeoutError, HTTPError, ConnectTimeout):
145
+ logging.error("Exception occurred while uploading given graph", exc_info=True)
169
146
  raise
170
147
 
171
148
 
@@ -174,4 +151,5 @@ def clear_graph(triple_store: dict, graph_uri: str):
174
151
  clear_query = f"CLEAR GRAPH <{graph_uri}>"
175
152
  query_azg(anzo_config=triple_store, query=clear_query, is_update=True)
176
153
  except (ConnectionError, TimeoutError, HTTPError, ConnectTimeout):
154
+ logging.error(f"Failed to clear graph {graph_uri} in triple store {triple_store['name']}")
177
155
  raise
@@ -529,21 +529,37 @@ class MustrdItem(pytest.Item):
529
529
 
530
530
  # Function called in the test to actually run it
531
531
  def run_test_spec(test_spec):
532
+ logger = logging.getLogger("mustrd.test")
533
+ logger.info(f"Running test spec: {getattr(test_spec, 'spec_uri', test_spec)}")
532
534
  if isinstance(test_spec, SpecSkipped):
535
+ logger.warning(f"Test skipped: {test_spec.message}")
533
536
  pytest.skip(f"Invalid configuration, error : {test_spec.message}")
534
- result = run_spec(test_spec)
535
- result_type = type(result)
537
+ try:
538
+ result = run_spec(test_spec)
539
+ logger.info(f"Result type: {type(result)} for spec: {getattr(test_spec, 'spec_uri', test_spec)}")
540
+ except Exception as e:
541
+ logger.error(f"Exception in run_spec for {getattr(test_spec, 'spec_uri', test_spec)}: {e}")
542
+ logger.error(traceback.format_exc())
543
+ raise # re-raise so pytest sees the error
544
+
536
545
  if isinstance(test_spec, SpecInvalid):
546
+ logger.error(f"Invalid test specification: {test_spec.message} {test_spec}")
537
547
  raise ValueError(f"Invalid test specification: {test_spec.message} {test_spec}")
538
- if result_type == SpecSkipped:
539
- # FIXME: Better exception management
548
+ if type(result) == SpecSkipped:
549
+ logger.warning("Test skipped due to unsupported configuration")
540
550
  pytest.skip("Unsupported configuration")
541
- if result_type != SpecPassed:
551
+ if type(result) != SpecPassed:
542
552
  write_result_diff_to_log(result, logger.info)
543
553
  log_lines = []
544
554
  def log_to_string(message):
545
555
  log_lines.append(message)
546
- write_result_diff_to_log(result, log_to_string)
556
+ try:
557
+ write_result_diff_to_log(result, log_to_string)
558
+ except Exception as e:
559
+ logger.error(f"Exception in write_result_diff_to_log: {e}")
560
+ logger.error(traceback.format_exc())
561
+ logger.error(f"Test failed: {log_lines}")
547
562
  raise AssertionError("Test failed: " + "\n".join(log_lines))
548
563
 
549
- return result_type == SpecPassed
564
+ logger.info(f"Test PASSED: {getattr(test_spec, 'spec_uri', test_spec)}")
565
+ return type(result) == SpecPassed
mustrd/steprunner.py CHANGED
@@ -165,20 +165,27 @@ def _multi_run_when_anzo_query_driven_update(spec_uri: URIRef, triple_store: dic
165
165
  def _spade_edn_group_source(spec_uri: URIRef, triple_store: dict, when: SpadeEdnGroupSourceWhenSpec):
166
166
  log.info(f"Running SpadeEdnGroupSource for {spec_uri} using {triple_store}")
167
167
 
168
- results = []
169
-
168
+ merged_result = None
170
169
  # Iterate over the list of WhenSpec objects in `when.value`
171
170
  for step_when_spec in when.value:
172
171
  try:
173
172
  log.info(f"Dispatching run_when for step: {step_when_spec}")
174
173
  query_result = run_when_impl(spec_uri, triple_store, step_when_spec)
175
174
  log.info(f"Executed SPARQL query: {query_result}")
176
- results.append(query_result)
175
+ # Merge results if possible (e.g., for Graphs), else just keep last non-None
176
+ if merged_result is None:
177
+ merged_result = query_result
178
+ else:
179
+ try:
180
+ merged_result += query_result # For graph-like objects
181
+ except Exception:
182
+ # If not mergeable, just keep the last result
183
+ merged_result = query_result
177
184
  except Exception as e:
178
185
  log.error(f"Failed to execute SPARQL query: {e}")
179
186
 
180
- log.debug(f"Final results: {results}")
181
- return results
187
+ log.debug(f"Final merged result: {merged_result}")
188
+ return merged_result
182
189
 
183
190
 
184
191
  @run_when_impl.method((TRIPLESTORE.RdfLib, MUST.SpadeEdnGroupSource))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mustrd
3
- Version: 0.3.1a8
3
+ Version: 0.3.1a9
4
4
  Summary: A Spec By Example framework for RDF and SPARQL, Inspired by Cucumber.
5
5
  License: MIT
6
6
  Author: John Placek
@@ -13,20 +13,20 @@ mustrd/model/test-resources/resources.ttl,sha256=1Dsp1nuNxauj9bxeX-HShQsiO-CVy5I
13
13
  mustrd/model/triplestoreOntology.ttl,sha256=9K5gj0hDOolRYjHc58UT4igex8cUnq9h7SUe4ToYbdw,5834
14
14
  mustrd/model/triplestoreshapes.ttl,sha256=G1kdgASdPa8s5JVGXL4KM2ewp-F5Vmbdist0f77VTBc,1706
15
15
  mustrd/mustrd.py,sha256=Ac42FUVY_6u1rt8uQmmIRo6-lV1vmOTy5fNu1CqPEIQ,41021
16
- mustrd/mustrdAnzo.py,sha256=0XhLkfagW_HManfZ3iGAf_K2_d-pLVTAOT-0pX8hhM4,8352
16
+ mustrd/mustrdAnzo.py,sha256=B5uwN17XBuIJu5IBE7GKZ_SuA8yLDzeKywVz3HzAWYI,7451
17
17
  mustrd/mustrdGraphDb.py,sha256=Ro_fxDPFl64r-FAM18awhZydydEY1-IXO0zdKpvZD3U,5405
18
18
  mustrd/mustrdRdfLib.py,sha256=1dYoyohjDhonKItYMNkFybySFt9lgez3zYN2kU9mW-I,2369
19
- mustrd/mustrdTestPlugin.py,sha256=hbYo8i1j4uFuRekXGd4Mnjt9wkSgQrS5o809xtbcLgs,19664
19
+ mustrd/mustrdTestPlugin.py,sha256=n6xISiYP1WrntcKOhtL0XZhdZigmBBHFfwrB5CEyV70,20577
20
20
  mustrd/namespace.py,sha256=1l8RJDFI7rYkWvmRokaTvSvqrDJEdRNIkq3lmPb0xpI,3854
21
21
  mustrd/run.py,sha256=5xZUgKPMBQ-03cWROAnwtbOs2Nb0Vat6n8Fi6EyfS-k,4257
22
22
  mustrd/spec_component.py,sha256=515XqP4Wc_TVaCOSswxTJM5i00bnuXvJZyEYa0N9_-o,38627
23
- mustrd/steprunner.py,sha256=dRdh9EaGhrEmIw9k52eJk-5hcQDjZTpr_A__oIkR-1E,10332
23
+ mustrd/steprunner.py,sha256=JnajkFay-oeSJnBH3OxFVGfz5WhKjxEH1PV4WUoRPRE,10752
24
24
  mustrd/templates/md_ResultList_leaf_template.jinja,sha256=IzwZjliCx7-viipATDQK6MQg_5q1kLMKdeNSZg1sXXY,508
25
25
  mustrd/templates/md_ResultList_template.jinja,sha256=_8joJ7vtw_qoqxv3HhUtBgRfhOeqmgfaRFwEo4MROvQ,203
26
26
  mustrd/templates/md_stats_template.jinja,sha256=96W62cMWu9UGLNv65ZQ8RYLjkxKHhJy-FlUtXgud6XY,155
27
27
  mustrd/utils.py,sha256=OGdLvw7GvjrFgTJo0J97Xwdh-_ZgSmapmOistrEchO0,1387
28
- mustrd-0.3.1a8.dist-info/LICENSE,sha256=r8nmh5fUct9h2w8_RDl13EIscvmwCLoarPr1kg35MnA,1078
29
- mustrd-0.3.1a8.dist-info/METADATA,sha256=wxb4aAokEJjdFTEmosNJBhS5-FotseE8lNdWW_2QZ6g,4109
30
- mustrd-0.3.1a8.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
31
- mustrd-0.3.1a8.dist-info/entry_points.txt,sha256=v7V7sN0_L1aB4Ug_9io5axlQSeJ1C0tNrQWwdXdV58s,50
32
- mustrd-0.3.1a8.dist-info/RECORD,,
28
+ mustrd-0.3.1a9.dist-info/LICENSE,sha256=r8nmh5fUct9h2w8_RDl13EIscvmwCLoarPr1kg35MnA,1078
29
+ mustrd-0.3.1a9.dist-info/METADATA,sha256=FEsCNbPWRPtwdNhp0D9GmiFULuCwy3on0YcAifeVzo0,4109
30
+ mustrd-0.3.1a9.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
31
+ mustrd-0.3.1a9.dist-info/entry_points.txt,sha256=v7V7sN0_L1aB4Ug_9io5axlQSeJ1C0tNrQWwdXdV58s,50
32
+ mustrd-0.3.1a9.dist-info/RECORD,,