Skip to content

Commit 6abc276

Browse files
committed
Resolved comments
1 parent c535456 commit 6abc276

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,5 +208,4 @@ cython_debug/
208208
!src/pynxtools/units/default_en.txt
209209
build/
210210
nexusparser.egg-info/PKG-INFO
211-
.python-version
212-
*.owl
211+
.python-version

src/pynxtools/nomad/ontology_service.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
from owlready2.namespace import Ontology
99
import subprocess
1010
from fastapi.responses import RedirectResponse
11-
from ..NeXusOntology.script.generate_ontology import main as generate_ontology
11+
from pynxtools.NeXusOntology.script.generate_ontology import main as generate_ontology
1212
import pygit2
13+
import logging
14+
logger = logging.getLogger("pynxtools")
1315

1416
#######################################################################
1517
########################## define app and functions ###################
@@ -18,8 +20,7 @@
1820

1921
# Define paths
2022
local_dir = os.path.dirname(os.path.abspath(__file__))
21-
nexusontology_dir = os.path.abspath(os.path.join(local_dir, "..", "NeXusOntology"))
22-
ontology_dir = os.path.join(nexusontology_dir, "ontology")
23+
ontology_dir = os.path.abspath(os.path.join(local_dir, "..", "NeXusOntology", "ontology"))
2324
OWL_FILE_PATH = None
2425

2526
def ensure_ontology_file():
@@ -57,7 +58,7 @@ def load_ontology() -> Ontology:
5758
ontology = get_ontology(inferred_owl_path).load()
5859
return ontology
5960
except Exception as e:
60-
print(f"Error loading ontology: {e}")
61+
logger.error(f"Error loading ontology: {e}")
6162
raise
6263

6364
def fetch_superclasses(ontology, class_name):
@@ -73,7 +74,7 @@ def fetch_superclasses(ontology, class_name):
7374
filtered_superclasses = [sc for sc in all_superclasses if str(sc) not in unwanted_superclasses]
7475
return [str(sc).split('.')[-1] for sc in filtered_superclasses]
7576
except Exception as e:
76-
print(f"Error in fetch_superclasses: {e}")
77+
logger.error(f"Error in fetch_superclasses: {e}")
7778
raise
7879

7980
#######################################################################
@@ -93,7 +94,7 @@ def startup_event():
9394
sync_reasoner(ontology)
9495
ontology.save(file=inferred_owl_path, format="rdfxml")
9596
except Exception as e:
96-
print(f"Error during startup: {e}")
97+
logger.error(f"Error during startup: {e}")
9798

9899
@app.get("/")
99100
def root():

src/pynxtools/nomad/schema.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ def normalize(self, archive, logger):
274274
logger.warning(
275275
f"Failed to fetch superclasses: {response.status_code} - {response.text}"
276276
)
277+
archive.results.ln.methods.append(class_name)
277278
else:
278279
logger.warning("entry.definition__field is missing or empty.")
279280
archive.results.eln.methods.append("Generic Experiment")
@@ -291,10 +292,6 @@ def normalize(self, archive, logger):
291292

292293
if archive.results.eln.methods is None:
293294
archive.results.eln.methods = []
294-
# if self.method:
295-
# archive.results.eln.methods.append(self.method)
296-
# else:
297-
# archive.results.eln.methods.append(self.m_def.name)
298295
if archive.workflow2 is None:
299296
archive.workflow2 = Workflow(name=self.name)
300297
# steps to tasks

0 commit comments

Comments
 (0)