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

Allow resources to be added dynamically to blaze server. #1329

Merged
merged 14 commits into from
Dec 8, 2015

Conversation

cowlicks
Copy link
Member

@cowlicks cowlicks commented Dec 1, 2015

I'm still having some trouble with this, just getting it out there for now.

closes #1177

@cowlicks
Copy link
Member Author

cowlicks commented Dec 2, 2015

API question:

A new data source is added to the severer by passing it a dictionary like {'data_name': data_resource}.

And recall that a blaze server is either instantiated with no data, a single data source, or a dict of data sources.

In the single data case, if I want to add {'foo': bar}, I have no name for my original data. And moving the original data source into a dictionary would change the datashape of the server. What should I name it?

Options:

  • All data on the blaze server must be in a dictionary, so we always have names for separate datasets. This breaks backward compatibility.
  • When adding a new datasource to a new blaze server, move the original data into a dictionary with some arbitrary name that can be learned by asking the server for its datashape.

I think option 1 is sensible.

@cowlicks
Copy link
Member Author

cowlicks commented Dec 2, 2015

cc @llllllllll @cpcloud

@cowlicks cowlicks force-pushed the add-to-blaze-server branch 2 times, most recently from a8beb25 to 9889079 Compare December 2, 2015 19:40
@llllllllll
Copy link
Member

The server always serves a single resource, the dictionary case is not special it is just that the single resource is itself a record. I could see only supporting the update if the resource is a mutable mapping.

@cowlicks
Copy link
Member Author

cowlicks commented Dec 3, 2015

Anything else y'all'd like to see?

data_not_mm_msg = ("Cannot update blaze server data since its current data"
" is a %s and not a mutable mapping (dictionary like).")
if not isinstance(data, collections.MutableMapping):
return (data_not_mm_msg % type(data), 400)
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this the right error code?

Copy link
Member

Choose a reason for hiding this comment

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

maybe a 422 Unprocessable Entity would be better here since the syntax of the message is okay:

The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions. For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.

@cowlicks
Copy link
Member Author

cowlicks commented Dec 3, 2015

Closes #1177

@cowlicks
Copy link
Member Author

cowlicks commented Dec 3, 2015

In #1177 @ywang007 mentions accessing data on the server URL's like http://localhost:6363/cities

Does this work? It is not working for me locally in a web browser.

@llllllllll
Copy link
Member

There is no data endpoint like that in the default blaze blueprint.

@cowlicks cowlicks changed the title WIP: allow resources to be added dynamically to blaze server. Allow resources to be added dynamically to blaze server. Dec 3, 2015
@@ -113,6 +114,32 @@ def authorized(*args, **kwargs):
return authorized


def check_request(f):
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this stuff to a decorator since it was copied in the compserver and addserver functions.

@cowlicks cowlicks added this to the 0.9.0 milestone Dec 3, 2015
@cpcloud
Copy link
Member

cpcloud commented Dec 4, 2015

@cowlicks LGTM, can you add a release note under Improved Backends? thx

@cpcloud
Copy link
Member

cpcloud commented Dec 4, 2015

@llllllllll any more feedback?

@cowlicks cowlicks force-pushed the add-to-blaze-server branch 2 times, most recently from ff7e1a7 to 8ac1a42 Compare December 4, 2015 18:29
@cowlicks
Copy link
Member Author

cowlicks commented Dec 4, 2015

Merging soon

@@ -25,6 +25,7 @@ Improved Backends

* Adds support for :func:`~blaze.expr.collections.tail` in the sql backend
(:issue:`1289`).
* Blaze Serever now supports dynamically adding datasets (:issue:`1329`).
Copy link
Member

Choose a reason for hiding this comment

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

typo here Serever -> Server

@cpcloud
Copy link
Member

cpcloud commented Dec 7, 2015

@cowlicks can you add a doc blurb in the blaze server docs showing a minimal working example?

@cowlicks
Copy link
Member Author

cowlicks commented Dec 7, 2015

@cpcloud the current example code with requests in the docs is not working for me. I'm working on it.

@@ -324,6 +324,22 @@ These queries deconstruct the Blaze expression as nested JSON. The ``":leaf"``
string is a special case pointing to the base data. Constructing these queries
can be difficult to do by hand, fortunately Blaze can help you to build them.

Adding Data to the Server
Copy link
Member Author

Choose a reason for hiding this comment

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

@cpcloud doc blurb

cowlicks added a commit that referenced this pull request Dec 8, 2015
Allow resources to be added dynamically to blaze server.
@cowlicks cowlicks merged commit 43d2f7e into blaze:master Dec 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow dynamic registering of new data source
3 participants