Last active
April 24, 2019 17:15
-
-
Save zeryx/c57cff9477dfa1d8bba4b5c609bdbfa2 to your computer and use it in GitHub Desktop.
Full Scala Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package algorithmia.Algorithm | |
import com.algorithmia._ | |
import com.algorithmia.algo._ | |
import com.algorithmia.data._ | |
import com.algorithmia.algorithmHandler._ | |
import com.google.gson._ | |
object Algorithm{ | |
def apply(input: String, context: Map[String, String]): String = { | |
s"Hello $input your file is available here ${context.get("local_path")}" | |
} | |
def download_model():Map[String, String] = { | |
val context: Map[String, String] = Map() | |
val client = Algorithmia.client("YOUR_API_KEY") | |
val local_path = client.file("data://demo/collection/somefile.json").getFile.getName | |
context + "local_path" -> local_path | |
context | |
} | |
def main(args: Array[String]): Unit = { | |
AlgorithmHandler(apply) | |
.setOnLoad(download_model) | |
.run() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package algorithmia.Algorithm | |
import com.algorithmia._ | |
import com.algorithmia.algo._ | |
import com.algorithmia.data._ | |
import com.algorithmia.algorithmHandler._ | |
import com.google.gson._ | |
object Algorithm{ | |
def apply(input: String): String = { | |
"Hello " + input | |
} | |
def main(args: Array[String]): Unit = { | |
AlgorithmHandler(apply) | |
.run() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment