Giter VIP home page Giter VIP logo

hydra-client-python's People

Contributors

jetuk avatar khaledk2 avatar knoxsp avatar pmslavin avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hydra-client-python's Issues

Cannot connect to hydraserver using RemoteJSONConnection

The RemoteJSONConnection example does not seem to work. I have tried both the version from pip and using the latest version (updated yesterday). Trying this:

import hydra_client as hc

hb_conn = hc.RemoteJSONConnection(url='http://localhost:8080/json')

hb_conn.login(username='root', password='')

gives me this:

Traceback (most recent call last):
File "base.py", line 19, in
hb_conn.login(username='root', password='')
File "C:\Users\honeywillrs\AppData\Local\Continuum\anaconda3\lib\site-packages\hydra_client\connection\remote_json_connection.py", line 112, in login
resp = self.call('login', login_params)
File "C:\Users\honeywillrs\AppData\Local\Continuum\anaconda3\lib\site-packages\hydra_client\connection\remote_json_connection.py", line 93, in call
raise RequestError(err)
hydra_client.exception.RequestError: {'message': "Client.AuthenticationError:Invalid authentication request for HydraError({'message': b'root', 'code': '0000'})", 'code': '200'}>

This was using Windows 10 and installed hydraserver via pip.

Pass arguments as kwargs instead of dict

I suggest revising the library to accept arguments as kwargs, instead of a dictionary of arguments. For example, instead of conn.add_network({'net': network}), one would call conn.add_network(net=network).

Here's my catchall code for a generic call to the hydra-server:

    def call(self, fn, **kwargs):
        # convert any boolean parameters to 'Y' or 'N'.
        for kwarg in kwargs.keys():
            if type(kwargs[kwarg]) == bool:
                kwargs[kwarg] = 'Y' if kwargs[kwarg] is True else 'N'
        return self._call(fn, kwargs)

I use this as conn.call('add_network', net=network). This could be modified to accommodate specific functions of course:

def add_network(self, **kwargs):
    return self.call('add_network', **kwargs)

Installation instructions are incorrect

The installation readme states to install like so:

pip install hydra-client

This is a completely unrelated package. The instructions should say:

pip install hydra-client-python

Make a CLI

Probably using a click.

Some example commands.

hydra-cli network delete 5

hydra-cli project add "My Awesome Project"

hydra-cli project rename "My Awesome Project" "My Very Awesome Project"

hydra-cli user list

Simplify and formalise the setting up, running and error handling of apps

Based on some discussion on app behaviour, it would be desireable to have a situation where we can simplify the 'main' code of an app which currently looks like (pseudocode):

def main():
    try:
         some_setup() #Parse arguments

         run_app_code() #Run The model / export the data, whatever

         some_teardown() #Write Logs, delete data, whatever

         message = 'Finished Successfully'

    except HydraError:
         message = 'Some known error has occurred'
    except Exception
         message = 'Some unknown error has occurred' 

    create_xml_response('MyApp', network_id, [scenario_id],, message=message) 

Could we get rid of the need to do this in every app, and let the client library handle it for us? This would also incorporate the ability to specify in the app whether you should raise the exception or write the xml response to stdout.

Show readable messages on apps login error

Problem

When an app do a login, if there is an error (username/password missing or incorrect) the login method raise an exception.
This is correct when there is the need to manage it at an higher level, but it is bad when the app is executed from the command line, because it is hard to understand that the problem was just a wrong login instead of something worse.

Solution

every app will have an additional switch "suppress_exception" so that in case of errors they will be showed with a friendly message (eg. "The username is mandatory" or "login info wrong") and the exception will not be shown.

Code suggestion to add in the app:

if self.suppress_exception:
    log.error("Unable to log in")
else:
    Raise("Unable to log in")

self.autocommit somehow being corrupted

I was having an issue (with MySQL) whereby commits were not happening as expected. For example, using hydra_client.call('add_project', new_project) would return the correct project, with a new ID, but the project wasn't committed to the DB.

I narrowed down the issue to self.autocommit in the hydra_client.JSONConnection somehow being corrupted. Whereas it defaults to True, it changes from True to some function (<function BaseConnection.getattr..wrapped at 0x00000187FB68A6A8>), so that if self.autocommit == True now becomes False, and no commits are made.

I'm not sure what the root cause is, but my band-aid fix seems to work: just set hc.autocommit = True before every call. I alread have hydra_client in my own custom wrapper class, so it's one line, but still this is an issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.