ivmfnal / metacat

Metadata Catalog
BSD 3-Clause "New" or "Revised" License
4 stars 5 forks source link

dealing with non-existent keywords. #3

Closed hschellman closed 1 year ago

hschellman commented 1 year ago

metacat query "files where user='calcuttj' limit 3" does this:

needs a more graceful way of saying that a keyword is unknown. Catch on server send a known error and then print that?

metacat query "files where user='calcuttj' limit 3" Traceback (most recent call last): File "/nashome/s/schellma/.local/bin/metacat", line 33, in sys.exit(load_entry_point('metacat==3.11.2', 'console_scripts', 'metacat')()) File "/nashome/s/schellma/.local/lib/python3.9/site-packages/metacat-3.11.2-py3.9.egg/metacat/ui/metacat_ui.py", line 91, in main cli.run(sys.argv, argv0="metacat") File "/nashome/s/schellma/.local/lib/python3.9/site-packages/metacat-3.11.2-py3.9.egg/metacat/ui/cli/cli.py", line 214, in run self._run(command, context, argv, usage_on_error) File "/nashome/s/schellma/.local/lib/python3.9/site-packages/metacat-3.11.2-py3.9.egg/metacat/ui/cli/cli.py", line 209, in _run return interp._run(pre_command + word, context, rest, usage_on_error = usage_on_error) File "/nashome/s/schellma/.local/lib/python3.9/site-packages/metacat-3.11.2-py3.9.egg/metacat/ui/cli/cli.py", line 106, in _run return self(command, context, opts, args) File "/nashome/s/schellma/.local/lib/python3.9/site-packages/metacat-3.11.2-py3.9.egg/metacat/ui/metacat_query.py", line 78, in __call__ results = client.query(query_text, namespace=namespace, with_metadata = with_meta, File "/nashome/s/schellma/.local/lib/python3.9/site-packages/metacat-3.11.2-py3.9.egg/metacat/webapi/webapi.py", line 765, in query results = self.post_json(url, query) File "/nashome/s/schellma/.local/lib/python3.9/site-packages/metacat-3.11.2-py3.9.egg/metacat/webapi/webapi.py", line 172, in post_json text = self.post_text(uri_suffix, data) File "/nashome/s/schellma/.local/lib/python3.9/site-packages/metacat-3.11.2-py3.9.egg/metacat/webapi/webapi.py", line 167, in post_text raise WebAPIError(url, response.status_code, response.text) metacat.webapi.webapi.WebAPIError: MetaCatServer error: URL: https://metacat.fnal.gov:9443/dune_meta_demo/app/data/query?with_meta=no&with_provenance=no HTTP status code: 500 Message: Message from the server:

Application error

Uncaught exception

Traceback (most recent call last):
  File "./metacat_server_dune/lib/metacat/mql/trees.py", line 308, in _walk
    try:    out = method(node, *children, **named_children)
  File "./metacat_server_dune/lib/metacat/mql/sql_converter.py", line 120, in basic_file_query
    sql = DBFileSet.sql_for_basic_query(self.DB, query)
  File "./metacat_server_dune/lib/metacat/db/dbobjects2.py", line 205, in sql_for_basic_query
    file_meta_exp = MetaExpressionDNF(basic_file_query.Wheres).sql(f) or "true"
  File "./metacat_server_dune/lib/metacat/db/dbobjects2.py", line 966, in sql
    return " or ".join([self.sql_and(t, table_name) for t in self.DNF])
  File "./metacat_server_dune/lib/metacat/db/dbobjects2.py", line 966, in 
    return " or ".join([self.sql_and(t, table_name) for t in self.DNF])
  File "./metacat_server_dune/lib/metacat/db/dbobjects2.py", line 832, in sql_and
    assert aname in DBFile.ColumnAttributes, f"Unrecognized file attribute {aname}"
AssertionError: Unrecognized file attribute user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/dbidata3/multiserver/webpie/webpie/WPApp.py", line 631, in wsgi_call
    response = method(request, relpath, **args)
  File "./metacat_server_dune/server/data_handler.py", line 838, in query
    results = query.run(db, filters=self.App.filters(), with_meta=with_meta, with_provenance=with_provenance, default_namespace=namespace or None,
  File "./metacat_server_dune/lib/metacat/mql/mql10.py", line 284, in run
    out = SQLConverter(db, filters, debug=debug).convert(optimized)
  File "./metacat_server_dune/lib/metacat/mql/sql_converter.py", line 63, in convert
    result = self.walk(tree)
  File "./metacat_server_dune/lib/metacat/mql/trees.py", line 280, in walk
    return self._walk(tree, debug)
  File "./metacat_server_dune/lib/metacat/mql/trees.py", line 310, in _walk
    raise SyntaxTreeConversionError(f"Error while processing node {node_type}({children}, {named_children}) ") from e
metacat.mql.trees.SyntaxTreeConversionError: Error while processing node basic_file_query([], {'query': }) 
ivmfnal commented 1 year ago

CLI was modified to catch and print nicely all MetaCat-generated exceptions. Please upgrade your client to 3.18.5. Canned lient is at: https://cdcvs.fnal.gov/redmine/projects/metacat/files