Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Add safety checks #10

Open
Shalmezad opened this issue Sep 13, 2017 · 0 comments
Open

Add safety checks #10

Shalmezad opened this issue Sep 13, 2017 · 0 comments

Comments

@Shalmezad
Copy link
Contributor

Playing around with the server so I can get a docker image fully up and running.
Tried doing a post request as noted in the README:
requests.post("http://localhost:5151/", json={'submission_id': '58d411e57278611200ee49a6', 'api_key': 'h/52y/E7cm8Ih4F3cVdlBM4ZQxER+Apk6P0L7yR0lFU='})
However, kept getting an error:

numerai-submission-server_1  |   File "/submission-criteria/database_manager.py", line 45, in update_leaderboard
numerai-submission-server_1  | TypeError: 'NoneType' object is not subscriptable

Finally figured it out in that the server is still somewhat tied to the Numerai platform in that it's expecting the submission to be in the attached mongo database.

Adding some safety checks with meaningful messages would help for those trying to get this running (and later, to start cutting it into pieces), such as assuming that the submission may not be in the database beforehand:

    def update_leaderboard(self, submission_id, filemanager):
        submission = self.db.submissions.find_one({"_id":ObjectId(submission_id)})

        if submission is None:
            logging.getLogger().info("Unable to find submission_id {}".format(submission_id))
            # No sense continuing:
            return # Depending on coding style. Could return nothing, could raise an error. 
xanderdunn added a commit that referenced this issue Nov 11, 2017
Added a check for an API key.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants