You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# API calls will begin at the apply() method, with the request body passed as 'input'
9
9
# For more details, see algorithmia.com/developers/algorithm-development/languages
10
10
11
11
defapply(input):
12
+
# If your apply function uses state that's loaded into memory via load, you can pass that loaded state to your apply
13
+
# function by defining an additional "state" parameter in your apply function; but it's optional!
12
14
return"hello {}".format(str(input))
13
15
14
16
15
-
algo = ADK(apply)
16
-
algo.serve("Algorithmia")
17
-
```
17
+
# This turns your library code into an algorithm that can run on the platform.
18
+
# If you intend to use loading operations, remember to pass a `load` function as a second variable.
19
+
algorithm = ADK(apply)
20
+
# The 'serve()' function actually starts the algorithm, you can follow along in the source code
21
+
# to see how everything works.
22
+
algorithm.init("Algorithmia")
18
23
24
+
```
25
+
## Focus
19
26
This document will describe the following:
20
27
- What is an Algorithm Development Kit
21
28
- Changes to Algorithm development
@@ -37,22 +44,182 @@ This kit, when implemented by an algorithm developer - enables an easy way to ge
37
44
38
45
Algorithm development does change with this introduction:
39
46
- Primary development file has been renamed to `src/Algorithm.py` to aide in understanding around what this file actually does / why it's important
40
-
- An additional import (`from adk import ADK`)
47
+
- An additional import (`from algorithm import ADK`)
41
48
- An optional `load()` function that can be implemented
42
49
- This enables a dedicated function for preparing your algorithm for runtime operations, such as model loading, configuration, etc
43
50
- A call to the handler function with your `apply` and optional` load` functions as inputs
44
51
-```python
45
-
algo= ADK(apply)
46
-
algo.serve("Algorithmia")
52
+
algorithm= ADK(apply)
53
+
algorithm.init("Algorithmia")
47
54
```
48
55
- Converts the project into an executable, rather than a library
49
56
- Which will interact with the `langserver` service on Algorithmia
50
57
- But is debuggable via stdin/stdout when executed locally / outside of an Algorithm container
51
-
- When a payload is provided to `serve()`, that payload will be directly provided to your algorithm when executed locally, bypassing stdin parsing and simplifying debugging!
58
+
- When a payload is provided to `init()`, that payload will be directly provided to your algorithm when executed locally, bypassing stdin parsing and simplifying debugging!
52
59
- This includes being able to step through your algorithm code in your IDE of choice! Just execute your `src/Algorithm.py` script andtry stepping through your code with your favorite IDE
53
60
54
61
## Example workflows
55
62
Check out these examples to help you get started:
56
-
- [hello world example](examples/hello_world)
57
-
- [hello world example with loaded state](examples/loaded_state_hello_world)
58
-
- [pytorch based image classification](examples/pytorch_image_classification)
- Example workflows you can use to create your own Algorithms.
11
+
12
+
13
+
## What is an Algorithm Development Kit
14
+
An Algorithm Development Kit is a package that contains all of the necessary components to convert a regular application into one that can be executed and run on Algorithmia.
15
+
To do that, an ADK must be able to communicate with [langserver](https://github.com/algorithmiaio/langpacks/blob/develop/langpack_guide.md).
16
+
To keep things simple, an ADK exposes some optional functions, along with an `apply` function that acts as the explicit entrypoint into your algorithm.
17
+
Along with those basics, the ADK also exposes the ability to execute your algorithm locally, without `langserver`; which enables better debuggability.
18
+
19
+

20
+
21
+
This kit, when implemented by an algorithm developer - enables an easy way to get started with your project, along with well defined hooks to integrate with an existing project.
22
+
23
+
24
+
## Changes to Algorithm Development
25
+
26
+
Algorithm development does change with this introduction:
27
+
- Primary development file has been renamed to `src/Algorithm.py` to aide in understanding around what this file actually does / why it's important
28
+
- An additional import (`from algorithm import ADK`)
29
+
- An optional `load()` function that can be implemented
30
+
- This enables a dedicated function for preparing your algorithm for runtime operations, such as model loading, configuration, etc
31
+
- A call to the handler function with your `apply` and optional` load` functions as inputs
32
+
-```python
33
+
algorithm = ADK(apply)
34
+
algorithm.init("Algorithmia")
35
+
```
36
+
- Converts the project into an executable, rather than a library
37
+
- Which will interact with the `langserver` service on Algorithmia
38
+
- But is debuggable via stdin/stdout when executed locally / outside of an Algorithm container
39
+
- When a payload is provided to `init()`, that payload will be directly provided to your algorithm when executed locally, bypassing stdin parsing and simplifying debugging!
40
+
- This includes being able to step through your algorithm code in your IDE of choice! Just execute your `src/Algorithm.py` script andtry stepping through your code with your favorite IDE
0 commit comments