Resource Function and Other Repository News

Bob Sandheinrich WTC 2018

Agenda

Resource and Repositories

Recap of existing Repositories

Function Repository

Formula Repository

A look at the future

Resource Objects and Repositories

A resource object represents content that is ready-to-use in the Wolfram Language.

ResourceObject["Space Shuttle 3D Model"]

Repositories are collections of resources with the same type of content approved by Wolfram Research and distributed via the Wolfram Cloud.

Data Repository

Released in 2017

Dataset@ResourceData["Meteorite Landings"]

GeoGraphics[{Red,Point@DeleteMissing[ResourceData["Meteorite Landings"][All,"Coordinates"]]},GeoRange->(Entity["Australia", Entity["Country","Australia"], "Entity[\"Country\", \"Australia\"]", "country"])]

Neural Net Repository

Released in early 2018

(HyperlinkURL["resources.wolframcloud.com/NeuralNetRepository", https://resources.wolframcloud.com/NeuralNetRepository])

Trained Neural Networks

ResourceObject["Colorful Image Colorization Trained on ImageNet Competition Data"]

Immediately Usable, with examples

netevaluation[img_Image]:=With[{lum=ColorSeparate[img,"L"]},Image[Prepend[ArrayResample[NetModel["Colorful Image Colorization Trained on ImageNet Competition Data"][lum],Prepend[Reverse@ImageDimensions@img,2]],ImageData[lum]],Interleaving->False,ColorSpace->"LAB"]]

img=CurrentImage[]
gray=ColorConvert[img,"Grayscale"];

img->gray->netevaluation[gray]

New functions powered by NetModels

ImageIdentify, ImageRestyle, FindFaces, FacialFeatures, ...

Function Repository

Released Right Now!

Using a Function From the Repository

Use the blob like a symbol

Get properties of a resource

ResourceObject <-> ResourceFunction

Creating your own ResourceFunction

Using DefineResourceFunction

bird=First@WebImageSearch["Bird Cartoon","Thumbnails",MaxItems->1]

littlebird=ImageResize[bird,100]

PutABirdOnIt[expr_]:=Labeled[expr,littlebird,Top]

PutABirdOnIt[Range[10]]

DefineResourceFunction[PutABirdOnIt]

ResourceFunction Details

Definitions including dependencies are included

f[x_]:=g[x+1];
g[x_]:=x^2
DefineResourceFunction[f,"fButAlsoG"]

Clear[g]

"resource function"[5]

Snapshot of time the resource is created

g[x_]:=x^3

"resource function"[5]

Each ResourceFunction has an internal symbol and dedicated context

ResourceFunction["resource function","Symbol"]

"symb"[20]

Attributes are supported

NeverAdd[expr_]:=If[FreeQ[Hold[expr],Plus],expr,"CAREFUL, ADDITION!"]
SetAttributes[NeverAdd,{HoldFirst}]
DefineResourceFunction[NeverAdd]

"resource function"[1+1]

"resource function"[Plot[Sin[x],{x,0,Pi}]]

"resource function"[Plot[Sin[x+1],{x,0,Pi}]]

Examine a resource function using tools like DownValues, Attributes, etc.

Attributes["resource function"]

Definition["resource function"]

Also, see properties using the ResourceObject

ro=ResourceObject["NeverAdd"]

ro["UUID"]

ResourceFunction is intended to work with DownValues

There a limits to when UpValues will work

whichdef[_]:="DownValue Used"
whichdef/:HoldPattern[Plot][HoldPattern[whichdef][_],___]:="UpValue Used";

Plot[whichdef[1],{x,0,1}]

DefineResourceFunction[whichdef]

If there is no DownValue defined for a non-holding pattern it will use an UpValue

Clear[whichdef2];whichdef[_]:="DownValue Used"
whichdef2/:HoldPattern[ListPlot][HoldPattern[whichdef2][__],___]:="UpValue Used";DefineResourceFunction[whichdef2]

ListPlot[whichdef2[x,y],{x,0,1}]

OK, but why?

Add metadata including documentation

Distribution

Creating your own ResourceFunction

Using a Definition Notebook

defNotebook=ResourceFunction["CreateResourceNotebook"]["Function"]

CreateNotebook["FunctionResource"] (* in v12 *)

Sharing a ResourceFunction

Sharing From the Definition Notebook

SetSelectedNotebook[defNotebook]

Using a shared ResourceFunction

ResourceFunction[CloudObject["user:rhennigan/ResourceFunctions/BirdPeek"]]

Sharing with CloudPublish

Submitting and Publishing

SetSelectedNotebook[defNotebook]

With ResourceSubmit

ResourceSubmit["resource function"]

What to Submit

A function you’ve always wanted to be in WL

Things we’ve missed

A tool focused on your domain

Something fun

Anything you’ve rewritten at least 10 times for different projects

Submission Process

Publisher Accounts

Use to submit to any repository

One publisher id for many users

Request a Publisher ID here:

Hyperlink["FunctionRepository/request-publisher-id >>","https://resources.wolframcloud.com/FunctionRepository/request-publisher-id"]

Hyperlink["Provisional Resource >>","https://resources.wolframcloud.com/FunctionRepository/resources/ImageColorize"]

$PublisherID="Bob"

Formula Repository

Public, but unannouced

A web interface to FormulaData

FormulaData Example

FormulaData["ElasticCollision"]

FormulaData["ElasticCollision","QuantityVariableNames"]

FormulaData["ElasticCollision",<|(QuantityVariable[(Subscript["v", 1,"i"]), "Speed"])->(Quantity[10, "m""/""s", meters per second, (("Meters")/("Seconds"))]),(QuantityVariable[(Subscript["v", 2,"i"]), "Speed"])->(Quantity[0.5, "c", speed of light, "SpeedOfLight"]),"(Subscript[m, 1])"->(Quantity[1, "sh tn", short ton, "ShortTons"]),"(Subscript[m, 2])"->(Quantity[1 (10^6), "g", grams, "Grams"])|>]

Using ResourceObject

ro=ResourceObject["Elastic Collision"]

FormulaData[ro]

Upcoming Repositories

API

Paclet

Notebook Archive

Demonstrations

Service Connections

Credits

Deploy Products and Services

Bradley Ashby

Richard Hennigan

Cody Woodard

Manu Abraham

(Row[, (Spacer1), "BirdPeek"])["PleaseStop"]

QA

Bob Sandheinrich
Deployed Products and Services
bobs@wolfram.com
resource-team@wolfram.com