Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: error code discovery #6003

Merged
merged 2 commits into from
Jun 7, 2019
Merged

cli: error code discovery #6003

merged 2 commits into from
Jun 7, 2019

Conversation

joshmoore
Copy link
Member

@joshmoore joshmoore commented Apr 11, 2019

Suggested by Damir, a few additional methods on the BaseControl
class permit discovering all errors codes for available plugins.

Example output for the state of this commit:

    $ bin/omero errors
    123	     admin	NOT_WINDOWS	'Not Windows'
    200	     admin	     SETUP	'Error during service user set up:  (%s) %s'
    201	     admin	   RUNNING	'%s is already running. Use stop first'
    201	    server	 NO_CONFIG	'No --Ice.Config provided'
    202	     admin	NO_SERVICE	'%s service deleted.'
    300	     admin	BAD_CONFIG	'Bad configuration: No IceGrid.Node.Data property'
    400	     admin	WIN_CONFIG	'%s is not in this directory. Aborting...      ...'
    666	     admin	  NO_WIN32	'Could not import win32service and/or win32evtlogutil'

see: https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=8676&p=20525#p20525

  • agreement on the output format
  • API finalization
  • review external plugins
  • review included plugins

Suggested by Damir, a few additional methods on the BaseControl
class permit discovering all errors codes for available plugins.

Example output for the state of this commit:

        $ bin/omero errors
        123	     admin	NOT_WINDOWS	'Not Windows'
        200	     admin	     SETUP	'Error during service user set up:  (%s) %s'
        201	     admin	   RUNNING	'%s is already running. Use stop first'
        201	    server	 NO_CONFIG	'No --Ice.Config provided'
        202	     admin	NO_SERVICE	'%s service deleted.'
        300	     admin	BAD_CONFIG	'Bad configuration: No IceGrid.Node.Data property'
        400	     admin	WIN_CONFIG	'%s is not in this directory. Aborting...      ...'
        666	     admin	  NO_WIN32	'Could not import win32service and/or win32evtlogutil'

see: https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=8676&p=20525#p20525
@joshmoore
Copy link
Member Author

Addition of hql.py shows some room for refactoring:

   52	       hql	 BAD_QUERY	'Bad query: %s'
   52	    search	 BAD_QUERY	'Bad query: %s'
   53	       hql	 NOT_ADMIN	'SecurityViolation: Current user is not an admin an...'
   53	    search	 NOT_ADMIN	'SecurityViolation: Current user is not an admin an...'
   67	       hql	  NO_QUIET	'Can't ask for query with --quiet option'
   67	    search	  NO_QUIET	'Can't ask for query with --quiet option'

@sbesson
Copy link
Member

sbesson commented May 28, 2019

Looking at it, overall 👍 about the beginning of the rationalization of these codes. A couple of immediate feedback from pure code review while considering the extension of decoupled CLI plugins to implement this functionality

@joshmoore
Copy link
Member Author

by wrapping self.raise_error( in a try/catch block to remain backwards-compatible?

I thought about that, but that leads to a good deal of verbosity.

Could these be declared as a static variable Control.ERRORS?

It'd be a different approach.

@jburel
Copy link
Member

jburel commented May 29, 2019

at the moment, implementing this API would force a hard-dependency on an OMERO.py 5.5.
This could be reviewed as part of the python decoupling

@jburel
Copy link
Member

jburel commented May 29, 2019

I think the report format gives a good indication of what is going on

@joshmoore
Copy link
Member Author

Could these be declared as a static variable Control.ERRORS?
It'd be a different approach.

@sbesson : any thoughts? Guess I'm trying to avoid pinning us down to the implementation for the moment. We agree to not change:

     def add_error(self, name, rcode, msg):
     def get_errors(self):
     def raise_error(self, name, *args):
     class Error(object):

in a breaking manner, introducing Error2 and friends if need be.

Copy link
Member

@sbesson sbesson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through the code once again. Overall the new API should keep existing code backwards-compatible i.e. plugins (core or decoupled) should be able to ignore the new API and use self.ctx.die() as previously. When implementing the new API, I think add_error and raise_error are the two main ones that need to be implemented.

At this stage, I am tempted to just get this in and start testing with decoupled plugins e.g. omero-cli-render once OMERO 5.5 is out. Worst case, it turns out to be inefficient and we can deprecate the new Errors class as well as the new methods.

There is also a submodule update as part of the PR, is that on purpose?

@joshmoore
Copy link
Member Author

There is also a submodule update as part of the PR, is that on purpose?

Definitely not. Force-pushed away. Otherwise, 👍

@jburel
Copy link
Member

jburel commented Jun 5, 2019

Worst case, it turns out to be inefficient and we can deprecate the new Errors class as well as the new methods.

In that case, do we mark it as "experimental"?

@joshmoore
Copy link
Member Author

In that case, do we mark it as "experimental"?

I defer to you guys. I'm happy to support this, but unless we mark it as "Experimental" we should all be more or less happy with it, since propagating changes to the plugins shouldn't be taken lightly.

@jburel jburel merged commit b9796dc into ome:develop Jun 7, 2019
@jburel jburel added this to the 5.5.0 milestone Jun 13, 2019
@joshmoore joshmoore deleted the error-codes branch November 26, 2019 11:03
@paulkorir
Copy link

paulkorir commented Oct 20, 2020

Do you have an exit code 44 anywhere? I get it when I run omero sessions login <param> && omero delete Image:<id> over ssh (and ssh has no exit 44).

@joshmoore
Copy link
Member Author

No, I'm not seeing an error code 44 either.

@paulkorir
Copy link

You might want to consider adding 177 to mean No results found.

(omero) [centos@centos7 ~]$ omero search  Image '^emd_5625-*'
Created session for [email protected]:4064. Idle timeout: 10 min. Current group: system
No results found.
(omero) [centos@centos7 ~]$ echo $?
177

@joshmoore
Copy link
Member Author

@paulkorir : 👍 Will get to ASAP, but as always PRs welcome!

@joshmoore
Copy link
Member Author

Hi @paulkorir, I've started ome/omero-py#266 but it looks like 177 is not registered anywhere. We'll need to look into who or what is raising it to make that PR useful to you. ~J

@joshmoore
Copy link
Member Author

Found the issue for 177. It's the code returned modulo 256:

python -c "import sys; sys.exit(433)"; echo $?
177

See https://stackoverflow.com/questions/4448339/how-to-bypass-the-0-255-range-limit-for-sys-exit-in-python for some more information. I'll likely continue investigating this via ome/omero-py#267

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants