sssom-py icon indicating copy to clipboard operation
sssom-py copied to clipboard

Instructions on how to pipe properly

Open matentzn opened this issue 3 years ago • 0 comments

Is this how it should work?

 sssom parse ontologies/ro.json -I obographs-json | sssom dosql -Q "SELECT * FROM df WHERE subject_id LIKE \"%ro%\"" -o mappings/ro.ols.sssom.tsv

Results in

Traceback (most recent call last):
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/pandasql/sqldf.py", line 61, in __call__
    result = read_sql(query, conn)
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/pandas/io/sql.py", line 592, in read_sql
    return pandas_sql.read_query(
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/pandas/io/sql.py", line 1557, in read_query
    result = self.execute(*args)
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/pandas/io/sql.py", line 1402, in execute
    return self.connectable.execution_options().execute(*args, **kwargs)
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1280, in execute
    return self._exec_driver_sql(
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1584, in _exec_driver_sql
    ret = self._execute_context(
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1851, in _execute_context
    self._handle_dbapi_exception(
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2032, in _handle_dbapi_exception
    util.raise_(
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1808, in _execute_context
    self.dialect.do_execute(
  File "/Users/matentzn/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: df

This works:

sssom parse ontologies/ro.json -I obographs-json -o mappings/ro.ols.sssom.tsv && sssom dosql mappings/ro.ols.sssom.tsv -Q "SELECT * FROM df WHERE subject_id LIKE \"%ro%\"" -o mappings/ro.ols.sssom.tsv

Could it be that the warning printed by the first process actually causes the pipe to fail? This is another problem I have: how to "quiet" sssom-py properly:

$ sssom parse ontologies/ro.json -I obographs-json --quiet
Usage: sssom parse [OPTIONS] INPUT
Try 'sssom parse --help' for help.

Error: No such option: --quiet

or

$ sssom --quiet parse ontologies/ro.json -I obographs-json
Usage: sssom [OPTIONS] COMMAND [ARGS]...
Try 'sssom --help' for help.

Error: No such command 'ontologies/ro.json'.
matentzn@mbp:~/ws/ols-mapping-commons (main) $ 

matentzn avatar Jun 01 '22 12:06 matentzn