Upgrade to Pro — share decks privately, control downloads, hide ads and more …

みんなでつかう RStudo Server のつくりかた (Tokyo.R #105)

みんなでつかう RStudo Server のつくりかた (Tokyo.R #105)

Tokyo.R #105 LT の発表です。

Hisawo Takase

April 22, 2023
Tweet

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ Tokyo.R #105 2 ‣ ໊લɿߴ੉ٱ෉ (@hisawotakase) ‣ ৬ۀɿͱ͋ΔίϯαϧςΟϯάϑΝʔϜͰΠϯϋ΢εΤϯδχΞΛ 


    ɹɹɹ΍ͬͯ·͢ʢσʔλϕʔε͕޷͖ʣ ‣ RྺɿTokyo.Rʹ͸͍ͩͿલ͔ΒࢀՃͯ͠Δ͚Ͳ… ‣ ۙگɿ࣮͸͚ͬ͜͏ڊঊͩͬͨ͜ͱΛ஌Γ·ͨ͠ɿ 
 
 

  2. 4 ‣ Rࣗମʹ͍ͭͯͷ࿩͸ʢͨͿΜʣग़͖ͯ·ͤΜɻ ‣ ۩ମతͳઃఆ͸ɺԼهςοΫϒϩάΛ͝ࢀর͍ͩ͘͞ɻ ‣ RStudio ServerΛGoogle Cloud RunͰखܰʹӡ༻͢Δ

    ‣ ʲ2022೥൛ʳRStudio ServerΛGoogle Cloud RunͰखܰʹӡ༻͢Δ ‣ RStudio ServerͰPythonΛ࢖͍͍ͨ ɹɹɹ(ࠓ೥౓͔Βߋ৽Ͱ͖ͯͳ͍͚Ͳɻɻ) ‣ ࠓ೔͸ͦ͜ˢʹॻ͔ͳ͔ͬͨ͜ͱΛओʹ͓࿩͠·͢ɻ …͓࿩͠͠ͳ͍͜ͱɿ Tokyo.R #105
  3. 7 γεςϜߏ੒ ‣ Google Cloud Runɿ ‣ Dockerͱ͍͏Ծ૝؀ڥͷ࣮ߦ؀ڥ 
 ʢTokyo.RͷDocker

    fi leΛϕʔεʹ͍͖ͤͯͨͩ͞·ͨ͠ʣ ‣ Քಇ͍ͯ͠Δͱ͖͚࣮ͩମԽ͢Δɿෆ࢖༻࣌ʹ͸ফ໓ 
 → අ༻͸࢖༻͍ͯ͠Δͱ͖͚ͩൃੜ͢Δ 
 → σʔλஔ͖ͬͺͳ͠Ͱ͏͔ͬΓྲྀग़ͱ͍͏ةݥ΋ݮΒͤΔ 
 ※ ࢖༻͢Δσʔλ͸GoogleεϓϨουγʔτ/Google Bigquery͔Β௚઀ಡΈࠐΉΑ͏ઃఆ ‣ Identitiy-Aware Proxyɿ ‣ લஈʹGoogleೝূΛஔ͍ͯɺڐՄͨ͠ΞΧ΢ϯτͷΈΞΫηεՄೳ ‣ ͦΕҎ֎͸ RStudio Server (on Cloud Run) ʹ౸ୡ͢Δલʹڋ൱ ‣ ۈ຿ઌͰ͸ Google Workspace Λ࢖༻ͯ͠ΔͷͰɺୀ৬ऀͷݖݶണୣ΋ෆཁ Tokyo.R #105
  4. 8 γεςϜࣨɾηΩϡϦςΟࣨʹঝೝΛಘΔ Tokyo.R #105 ‣ ࢲͷۈ຿ઌͰ͸ɺൃ஫ਃ੥ͳͲͷঝೝϧʔτʹγεςϜࣨɾηΩϡϦςΟ͕ࣨೖͬͯ·͢ 
 →ͦͷਃ੥ʹɺ͜Μͳײ͡ͷίϝϯτΛ͚ͭ·ͨ͠ ʢ͕͢͞ʹͦͷ··ެ։ͩͱͳΜ͔ݴΘΕͦ͏ͳͷͰɺएׯ΅͔ͯ͠·͢ʣ ։ൃνʔϜͰओ࠵͍ͯ͠Δσʔλ෼ੳɾ౷ܭֶͷࣾ಺ษڧձ

    (౷ܭֶಓ৔) Ͱ࢖༻͢ΔRݴޠͷ࣮ߦ؀ڥ (RStudio Server) ͷΠϯϑϥ࢖༻ྉ Ͱ͢ɻ ʲֹۚ಺༰ͷઆ໌ʳ 2022೥౓ͷ࣮੷஋͕ฏۉͯ͠ 3,000ԁ/݄ ఔ౓Ͱ͋ͬͨͨΊɺ3,000ԁ * 12ϱ݄ * 1.1(ফඅ੫10%) = 39,600ԁ/೥ ͱࢉग़͠·ͨ͠ɻ අ༻ͷେ෦෼ (໿2,500/݄) ͸ηΩϡϦςΟͷͨΊͷϩʔυόϥϯα࢖༻ྉͰ͢ (ID/PWʹΑΔϩάΠϯը໘ͷલஈʹGoogleͷOAuthೝূΛ ஔ͍ͯอޢ͍ͯ͠·͢) ɻຊษڧձͰ͸ۀ຿σʔλΛ୊ࡐʹͯ͠ͷ෼ੳ/σΟεΧογϣϯ (֤෦໳ͷ্௕ʹΑΔྃঝࡁΈ) ΋ߦ͍ͬͯΔͨ ΊɺສશΛظͯ͜͠ͷߏ੒ʹͨͨ͠Ίʹඅ༻͕ൃੜ͍ͯ͠·͢ɻ ͳ͓࣮ߦ؀ڥ༻ͷαʔόΠϯϑϥ (Google Cloud Run) ͸ෆ࢖༻࣌ʹΠϯελϯε͕ফ໓͠σʔλ΋ফ͑ΔͨΊɺۀ຿σʔλ͕αʔό্ʹ ࢒Γଓ͚Δͱ͍͏͜ͱ͸͋Γ·ͤΜɻ → ແࣄɺ௨Γ·ͨ͠ʂ
  5. 9 ͲΜͲΜઃఆ͢Δ ‣ Tokyo.R͔Βɺಛʹ @bob3bob3 ͞Μ͔Βͨ͘͞ΜڭΘΓ·ͨ͠ʂ ‣ GGally, Summarytools (Tokoy.R

    #99 ύʔϚʔεςʔγϣϯͷϖϯΪϯͨͪ #1) 
 
 ‣ Python (Tokyo.R΋100ճ໨ͳͷͰɺ ͦΖͦΖPythonͱ஥ྑ͍ͨ͘͠) Tokyo.R #105 # for GGally and Summarytools # https://github.com/dcomtois/summarytools#required-debian RUN apt-get -y update && apt-get -y install libmagick++-dev libtk8.6 libtcl8.6 RUN Rscript -e "install.packages(c( \ 'GGally', \ 'summarytools'))" # for python 3.11 RUN apt-get -y install software-properties-common RUN add-apt-repository ppa:deadsnakes/ppa RUN apt-get -y update && apt-get -y install python3.11 python3.11-dev python3-pip python3.11-venv curl RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 100 RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 90 RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11 RUN pip install numpy scipy pandas lightgbm optuna RUN Rscript -e "install.packages('reticulate')"