Saving with another name and when re-opening, the load() doesn't work

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Saving with another name and when re-opening, the load() doesn't work

Luis Antonio Rodriguez
Hi,

I have an owl file with a specific taxonomy about Flight Plans published on the internet and my intention is:

1- To  use it as a model to be downloaded, putted in RAM memory to be manipulated (like an user filling a Web form with several fields)
2- To save this filled model as another independent owl file with another name.

Ok, I have used the save("TestandoPersistencia") and Python have persisted the file on my disk. When I try to use this persisted file like this:

"onto2 = get_ontology("file:///home/rodriguez/Desktop/Only_Dev_CodigoFonte/TestandoPersistencia")
onto2.load()"

Python answers like this:
"
  File "/home/rodriguez/Desktop/Only_Dev_Codigo_Fonte/PlanoDeVoo_SITRAER.py", line 17, in <module>
    onto2.load()

  File "/home/rodriguez/.local/lib/python3.8/site-packages/owlready2/namespace.py", line 913, in load
    fileobj = open(f, "rb")

FileNotFoundError: [Errno 2] No such file or directory: '/home/rodriguez/Desktop/Only_Dev_CodigoFonte/TestandoPersistenciaDesespero'"

If I don't use the onto.load(), like this:

"onto2 = get_ontology("file:///home/rodriguez/Desktop/Only_Dev_CodigoFonte/TestandoPersistenciaDesespero")
#onto2.load()
print(list(onto2.classes()))
print(list(onto2.individuals()))
print("&&&&&&&&")
print(onto2.base_iri)"

Python works, but answers there is no Classes or Individuals, but they are all there!!!

"runfile('/home/rodriguez/Desktop/Only_Dev_Codigo_Fonte/PlanoDeVoo_SITRAER.py', wdir='/home/rodriguez/Desktop/Only_Dev_Codigo_Fonte')
[]
[]
&&&&&&&&
file:///home/rodriguez/Desktop/Only_Dev_CodigoFonte/TestandoPersistencia#"

Python shows the file and its IRI bu says it is empty for classes and individuals. If I open the saved ontology with a text editor, the classes and individuals are there...

What is happening?
Reply | Threaded
Open this post in threaded view
|

Re: Saving with another name and when re-opening, the load() doesn't work

Luis Antonio Rodriguez
I have found the mistake: When we use the save() method owlready2 puts the file into the same folder the file .py is.
When I've tried to specify the path like this: ("/home/rodriguez/Desktop/MyFileExample.owl") the get_ontology method didin't found any file, besides it is the correct path
I've got the entire adress off the path and the code stayed like this: onto2 = get_ontology("MyFileExample.owl"). It has worked and owlready shows classes and individuals normally.

Thanks everyone!