-
Notifications
You must be signed in to change notification settings - Fork 2
More complex quick start examples to introduce other concepts #17
Conversation
quick_start/more.rst
Outdated
| Building NStack Container module irisclassify. Please wait. This may take some time. | ||
| Module irisclassify built successfully. Use `nstack list methods` to see all available methods. | ||
|
|
||
| We can see our method, ``irisclassify.predict``. Including our ``demo.numChars`` method from the previous tutorial, we should now have two: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line reads oddly - presumably you mean something like:
We can now see
irisclassify.predictin the list of existing methods (along with previously built methods likedemo.numChars) by running the suggested commandnstack list methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thank you
quick_start/more.rst
Outdated
| .. code :: bash | ||
|
|
||
| ~/irisclassify/ $ curl -X PUT -d '{ "params" : [4.7, 1.4, 6.1, 2.9] }' localhost:8080/irisendpoint | ||
| Success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of Success we now see Msg Accepted here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
quick_start/more.rst
Outdated
| ~/irisclassify/ $ nstack log 2 | ||
| Feb 17 10:32:30 nostromo nstack-server[8925]: OUTPUT: "Iris-versicolor" | ||
|
|
||
| Great! Our classifiier is now productionised. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in classifiier
quick_start/more.rst
Outdated
|
|
||
| Great! Our classifiier is now productionised. | ||
|
|
||
| Other Sources and Sinks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if a better header here would be Connecting to a Database - it's more user-story focused, perhaps more compelling?
quick_start/more.rst
Outdated
|
|
||
| ~/irisworkflow/ $ nstack start irisworkflow.completeWorkflow | ||
|
|
||
| This paradigm can be helpful when we apply it to sources and sinks. Oftentimes, you -- or someone else in your company -- will want to create sources and sinks which are combined with modules, for instance in the following fictional example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should build a practical example here that someone can go through, for defining sources and sinks?
E.g. define a reusable http endpoint:
def irisEndpoint = source(http:///irisclassify : (Double,Double,Double,Double))
Which they can then use and test? Or we stick with Postgres but make sure we actually have a test db on the server they can use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the former, I think we should mention the latter as well though.
… more content for partial workflows, add new syntax
|
The last more complex example should probably be split into sections IMO |
quick_start/more.rst
Outdated
| .. code :: python | ||
|
|
||
| def __init__(self): | ||
| train = pd.read_csv("train.csv") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even our examples escape our type system!
Not a criticism as it seems like its actually the main use case
advanced_start/index.rst
Outdated
| Advanced Tutorial | ||
| ****************** | ||
|
|
||
| In this section, we're going to productionise a Random Forest classifier written with `sklearn`, deploy it to the cloud, and use it in a more sophisticated workflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
link to what sklearn is (and probably likewise with random forest)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really really have to use "productionise"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point on the former. On the latter, it's quite a common term but is a bit clunky. Do you prefer operationalise?
advanced_start/more.rst
Outdated
| ~/irisclassify/ $ nstack init python | ||
| python module 'irisclassify' successfully initialised at ~/irisclassify | ||
|
|
||
| Next, let's download our training data into this so we can use it in our module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
into this -> into this directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(or just remove it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
advanced_start/more.rst
Outdated
| Defining our API | ||
| **************** | ||
|
|
||
| As we know what the input and output of our classifier is going to look like, let's edit the ``api`` section of ``nstack.yaml`` to define our API (i.e. the entry-point into our module). By default a new module contains a sample function ``numChars``, which we can replace with our definition. We're going to call the function we write in Python ``predict``, which means we can fill in the ``api`` section of ``nstack.yaml`` as follows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can fill in -> we fill in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
advanced_start/more.rst
Outdated
|
|
||
| .. note :: Python modules must also import ``nstack`` | ||
|
|
||
| Before we add our ``predict`` function, we're going to add ``__init__``, the Python contructor function which runs upon the creation of our module. It's going to load our data from ``train.csv``, and use it to train our Random Forest classifier: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contructor -> constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
advanced_start/more.rst
Outdated
|
|
||
| .. code :: yaml | ||
|
|
||
| packages: ['numpy', 'python3-scikit-learn.x86_64', 'scipy', 'python3-scikit-image.x86_64', 'python3-pandas.x86_64'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it sucks that we have to specify architecture for some of these - is that definitely the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not - can it be left out typically with dnf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup
advanced_start/more.rst
Outdated
| Building NStack Container module irisclassify. Please wait. This may take some time. | ||
| Module irisclassify built successfully. Use `nstack list functions` to see all available functions. | ||
|
|
||
| We can now see ``irisclassify.predict`` in the list of existing functions (along with previously built functions like demo.numChars) by running the suggested command nstack list functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
demo.numChars -> demo.numChars perhaps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by running the suggested command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
advanced_start/more.rst
Outdated
| irisclassify.predict : (Double, Double, Double, Double) -> Text | ||
| demo.numChars : Text -> Integer | ||
|
|
||
| Our classifier is now published, but to use it we need to connect it to an event-source and sink. In the previous tutorial, we used HTTP as a source, and the NStack log as a sink. We can do the same here by starting the following workflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an event source and a sink
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
advanced_start/workflow_power.rst
Outdated
|
|
||
| .. code :: bash | ||
|
|
||
| module irsiworkflow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
irsi -> iris
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch..
advanced_start/workflow_power.rst
Outdated
| Partial workflows | ||
| ***************** | ||
|
|
||
| All of the workflows that we have written so far have been `fully composed`, which means that they contain a source, one or more functions, and a sink. Many times, you want to split up sources, sinks, and functions into separate pieces you can share and reuse. In this case, we say that a workflow is `partially composed`, which just means it does not contain a source, one or more functions, and a sink. These workflows cannot be ``start``\ed by themselves, but can be shared and attached to other sources, sinks, or functions to become `fully composed`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I create a workflow that's just a source and a sink?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a common theme for data integration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so "one or more functions" should be "zero or more functions"? (but would suggest tweaking the wording)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good for now (please squash)
|
It's still probably incomplete at then end (it doesn't really have a conclusion), and it stills needs to be changed to use the newest UX syntax on modules and DSL. |
rjmk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just looked at the first file so far
advanced_start/more.rst
Outdated
|
|
||
| .. code:: bash | ||
|
|
||
| ~/ $ mkdir Irisclassify; cd Irisclassify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to follow the directory structure of the examples, this should be Iris.Classify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I'll update everything to use this format.
advanced_start/more.rst
Outdated
|
|
||
| .. code:: bash | ||
|
|
||
| ~/Irisclassify/ $ curl -O https://raw.githubusercontent.com/nstackcom/nstack-examples/master/iris/irisclassify/train.csv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
advanced_start/more.rst
Outdated
| api : | | ||
| predict : (Double, Double, Double, Double) -> Text | ||
|
|
||
| This means we are exposing a single function ``predict``, which takes a record of four ``Double``\s (the measurements) and returns ``Text`` (the iris species). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be kind of cool to show off sum types here. How many species are there?
advanced_start/more.rst
Outdated
|
|
||
| .. code :: bash | ||
|
|
||
| ~/Irisclassify/ $ nstack start "sources.http<(Double, Double, Double, Double)> { http_path : "/irisendpoint" } | irisclassify.predict | sinks.log<Text>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sadly still not possible. You need a complete workflow for nstack start which could be referenced unqualified. The current example has a workflow and a project yaml, which could be recreated?
|
This is now ready for review to merge. |
What does this PR do?
I've added another section in quick_start to:
Notes