INCATools / INCATools/ontology-access-kit

Misc small `SqlImplementation` issues

Open
#294 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
198
Forks
35
Avg merge
3d 4h
Merged PRs (30d)
1

Description

I was going to make an issue about having a problem with `SqlImplementation.entities()` not getting any entities and producing errors, but I think I'm having more general problems with `SqlImplementation`.

**My version:** `oaklib==0.1.23`
_edit:_ I realize now that this is outdated. I fixed that on my end. I will need to re-run and see if still empty.

# Sub-issue list
Checked means fixed.
- [ ] 1. Orphan `.template.db.tmp`
- [ ] 2. Unsquelched `stdout`
- [ ] 3. Unhandled error: missing local file
- [ ] 4. Interactive `sqlite` session when running Python script from makefile
- [ ] 5. `.entities()` returns nothing

# Sub-issues
## 1. Orphan `.template.db.tmp`
I think that it hung at some point; possibly related to issue (4) below. I think that when I terminated, OAK did not exit gracefully and delete this temp file from the directory where I called.

This still applies to `0.2.0`, when using OAK or `semsql` separately.

Related: https://github.com/INCATools/semantic-sql/issues/47

## 2. Unsquelched `stdout`
Last tried version: `0.1.23`
I don't know if this is useful to some users. I'd prefer not seeing it by default.

**What I ran**
From Python:
```py
ontology = SqlImplementation(OntologyResource(slug='mondo-ingest/src/ontology/components/omim.owl', local=True))
```

**Output**
```
cat /Users/joeflack4/virtualenvs/mondo-ingest/lib/python3.9/site-packages/semsql/builder//sql_schema/semsql.sql | sqlite3 .template.db.tmp && \
echo .exit | sqlite3 -echo .template.db.tmp -cmd ".mode csv" -cmd ".import /Users/joeflack4/virtualenvs/mondo-ingest/lib/python3.9/site-packages/semsql/builder//prefixes/prefixes.csv prefix" && \
mv .template.db.tmp .template.db
.exit
robot remove -i components/omim.owl --axioms "equivalent disjoint annotation" -o components/omim-min.owl
relation-graph --disable-owl-nothing true \
--ontology-file components/omim-min.owl\
--output-file components/omim-relation-graph.tsv.ttl.tmp \
--equivalence-as-subclass true \
--output-subclasses true \
--reflexive-subclasses true && \
```

**Possible solutions**
Add a `bool` argument `verbose` to the necessary super / interface classes, defaulting to `False`. Can then connect this to the CLI with a `--verbose` option.

## 3. Unhandled error: missing local file
I ran Python from my IDE:
```py
ontology = SqlImplementation(OntologyResource(slug='components/omim.owl', local=True))
```

But I think it had the wrong working directory at first, and I got this error:
> `make: *** No rule to make target `components/omim.db'. Stop.`

Suggestion:
Handle this exception and instead show something like:
> FileNotFoundError: 'components/omim.owl'

## 4. Interactive `sqlite` session when running Python script from makefile
My Python script got ran from a `makefile`. I believe that this is the line which triggered the following terminal output:
```py
ontology = SqlImplementation(OntologyResource(slug='components/omim.owl', local=True))
```

Terminal output:
```
/usr/local/lib/python3.10/dist-packages/rdflib_jsonld/__init__.py:9: DeprecationWarning: The rdflib-jsonld package has been integrated into rdflib as of rdflib==6.0.0. Please remove rdflib-jsonld from your project's dependencies.
warnings.warn(
make[1]: Entering directory '/work/src/ontology'
cat /usr/local/lib/python3.10/dist-packages/semsql/builder//sql_schema/semsql.sql | sqlite3 .template.db.tmp && \
sqlite3 -echo .template.db.tmp -cmd ".mode csv" -cmd ".import /usr/local/lib/python3.10/dist-packages/semsql/builder//prefixes/prefixes.csv prefix" -cmd ".exit" && \
mv .template.db.tmp .template.db
SQLite version 3.37.2 2022-01-06 13:25:41
Enter ".help" for usage hints.
sqlite>
```

This may be related to my issue (1) above. I think when I quit this, it may have left remnants of some temp DB file, but I'm not sure.

Also at some point, my terminal froze, and I tried CTRL+D plus like 7 other ways to try to kill the process, but I couldn't terminate and ultimately had to close the window. It may have been related to this issue; not sure.

## 5. `.entities()` returns nothing
This was the case for `0.1.23`. I haven't tried again using `0.2.0`, though I did see that my `0.2.0` DB that was created manually by `semsql` was not empty.

Related: https://github.com/INCATools/semantic-sql/issues/48

Contributor guide

Open the contributing guide

Research direction

Start at SqlImplementation and its entities() entry point, then inspect the makefile commands and semsql/sqlite setup described in the report. Reproduce the five listed behaviors against the current version, since several observations were made on outdated releases. Done means each confirmed issue has a clear error or output behavior, with temporary files and interactive sessions handled appropriately.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlite
Domain
backend, cli, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.