{"id":17153883,"url":"https://github.com/stevenmmortimer/pothole","last_synced_at":"2025-03-24T13:23:48.970Z","repository":{"id":95730444,"uuid":"47725951","full_name":"StevenMMortimer/pothole","owner":"StevenMMortimer","description":"Edmonton Pothole Prediction Service","archived":false,"fork":false,"pushed_at":"2016-01-22T05:50:34.000Z","size":812,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T18:28:32.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://public.opencpu.org/ocpu/github/ReportMort/pothole/www","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StevenMMortimer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-09T23:34:58.000Z","updated_at":"2017-11-06T07:03:09.000Z","dependencies_parsed_at":"2023-04-18T16:48:27.839Z","dependency_job_id":null,"html_url":"https://github.com/StevenMMortimer/pothole","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenMMortimer%2Fpothole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenMMortimer%2Fpothole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenMMortimer%2Fpothole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StevenMMortimer%2Fpothole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StevenMMortimer","download_url":"https://codeload.github.com/StevenMMortimer/pothole/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245276806,"owners_count":20589035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T21:47:34.770Z","updated_at":"2025-03-24T13:23:48.946Z","avatar_url":"https://github.com/StevenMMortimer.png","language":"JavaScript","readme":"Deploy Edmonton Pothole Prediction Model\n====================\n\nThis package was created to illustrate how to deploy an R model as an API using OpenCPU. \nThe model is included in the `data` directory of the package, and was created\nusing the [createmodel.R](https://github.com/reportmort/pothole/blob/master/inst/pothole/createmodel.R) script. \nIt predicts number of potholes filled monthly in Edmonton.\n\nBelow are a set of various commands for hitting the API after it's been created per\ninstructions laid out by OpenCPU\n\n    # Install \u0026 Score in R\n    library(devtools)\n    install_github(\"ReportMort/pothole\")\n    library(pothole)\n    mydata \u003c- data.frame(month=c(\"2016-01-01\"))\n    pothole_predict(input = mydata)\n\n    # Score from model deployed on opencpu servers\n    curl https://public.opencpu.org/ocpu/github/ReportMort/pothole/R/pothole_predict/json \\\n      -H \"Content-Type: application/json\" \\\n      -d '{\"input\" : [ {\"month\":\"2016-01-01\"} ]}'\n      \n    # Score from R using RCurl\n    library(RCurl)\n    library(RJSONIO)\n    res \u003c- postForm(\"https://public.opencpu.org/ocpu/github/ReportMort/pothole/R/pothole_predict/json\",\n            .opts = list(postfields = toJSON(list(input=list(month=\"2016-01-01\"))),\n            httpheader = c('Content-Type' = 'application/json', Accept = 'application/json'),\n            ssl.verifypeer = FALSE))\n    fromJSON(res)\n      \n    # Score using Vagrant and Virtualbox\n    # First setup virtual machine, copy package to it, ssh into it and install, and run curl against that machine\n    scp -P 2222 /cygdrive/c/users/steven.mortimer/documents/personal-github/pothole_0.0.1.tar.gz vagrant@127.0.0.1:~/.\n    vagrant ssh\n    sudo R CMD INSTALL pothole.0.0.1.tar.gz --library=/usr/local/lib/R/site-library\n    curl http://10.68.12.119/ocpu/library/pothole/R/pothole_predict/json \\\n      -H \"Content-Type: application/json\" \\\n      -d '{\"input\" : [ {\"month\":\"2016-01-01\"} ]}'\n      \n\nFor users who prefer to not use public hosting provided by OpenCPU\nbelow is a vagrant script for deploying on AWS.\n\n```\naccess_key_id = ENV['AWS_ACCESS_KEY_ID']\nsecret_access_key = ENV['AWS_SECRET_ACCESS_KEY']\n\nVagrant.configure(\"2\") do |config|\n\n\tconfig.vm.box = \"dummy\"\n\t\n\tconfig.vm.provider :aws do |aws, override|\n\t\taws.access_key_id = access_key_id\n\t\taws.secret_access_key = secret_access_key\n\t\taws.keypair_name = \"your-keypair-name\"\n\t\taws.region = \"us-west-2\"\n\t\taws.instance_type = \"t2.micro\"\n\t\taws.ami = \"ami-07677666\"\n\t\taws.security_groups = ['name-of-your-security-group']\n\n\t\toverride.ssh.username = \"ubuntu\"\n\t\toverride.ssh.private_key_path = \"/path/to/your/private/key.pem\"\n\t\n\tend\n\n$script = \u003c\u003cBOOTSTRAP\n\n# Install system level dependencies\nsudo apt-get update\nsudo apt-get upgrade\nsudo apt-get build-dep -y libcurl4-gnutls-dev\nsudo apt-get build-dep -y libcurl4-openssl-dev\nsudo apt-get install -y libcurl4-openssl-dev\nsudo apt-get install -y git gcc\nsudo apt-get install -y gdebi-core\nsudo apt-get install -y libapparmor1\nsudo apt-get install -y openjdk-7-jre-headless\nsudo apt-get install -y apt-file\nsudo apt-file update\n\n# Install the development version of base R\necho \"deb http://cran.rstudio.com/bin/linux/ubuntu trusty/\" | sudo tee --append /etc/apt/sources.list \u003e /dev/null\nsudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9\nsudo add-apt-repository ppa:marutter/rdev\nsudo apt-get update\nsudo apt-get -y install r-base r-base-dev\n\n# Install RStudio for the convenience of working directly on the server\nwget -q https://download2.rstudio.org/rstudio-server-0.99.489-amd64.deb\ngdebi -n rstudio-server-0.99.489-amd64.deb\nchmod -R 777 /usr/lib/R/site-library\nchmod -R 777 /usr/share/R/doc\n\n# Add a user to be able to access RStudio Server\nsudo useradd -d /home/rstudio -m rstudio\necho -e \"pass\\npass\" | (sudo passwd rstudio)\n\n# install the R packages required for this prediction API\nsudo R -e \"install.packages(c('forecast', 'zoo', 'lubridate'), repos = 'http://cran.rstudio.com/', dep = TRUE)\"\n\n# Prevent postfix from prompting for hostname\nsudo debconf-set-selections \u003c\u003c\u003c \"postfix postfix/mailname string your.hostname.com\"\nsudo debconf-set-selections \u003c\u003c\u003c \"postfix postfix/main_mailer_type string 'Internet Site'\"\nsudo apt-get install -y postfix\n \n# Install OpenCPU\nsudo add-apt-repository -y ppa:opencpu/opencpu-1.5\nsudo apt-get update\nsudo apt-get install -y opencpu-server\n\n# Install the package for this prediction API\nsudo R -e \"install.packages('/vagrant/pothole_0.0.1.tar.gz', repos=NULL, type='source')\"\n\nBOOTSTRAP\n\n  config.vm.provision :shell, :inline =\u003e $script\n  \nend\n```\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenmmortimer%2Fpothole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevenmmortimer%2Fpothole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenmmortimer%2Fpothole/lists"}