<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Web U Project</title>
    <description>地方移住を目指すウェブ技術屋のページ。Python / Data / AWS / GCP</description>
    <link>https://web-u-project.com/</link>
    <atom:link href="https://web-u-project.com/feed.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>CircleCIはじめました</title>
      <description>&lt;p&gt;以前の職場で用意した資料を一部修正して公開します。&lt;/p&gt;

&lt;p&gt;CI/CDとはなにか、CircleCIでどんなことができるのかを紹介し、
実際にどういった設定、操作ができるのかをまとめました。&lt;/p&gt;

&lt;p&gt;補足には近しいサービスと簡単な特徴を記載しておきます。&lt;/p&gt;

&lt;h2 id=&quot;cicd-continuous-integration-continuous-delivery&quot;&gt;CI/CD: Continuous Integration, Continuous Delivery&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;アプリケーション作成時の品質改善のための手法&lt;/li&gt;
  &lt;li&gt;具体的にはテストやデプロイの自動化の仕組みを用意すること&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;circleci-とは&quot;&gt;CircleCI とは&lt;/h2&gt;

&lt;p&gt;CI/CDの仕組みを提供するSaasタイプのサービス&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://circleci.com/product/&quot;&gt;https://circleci.com/product/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;何をしてくれるのか&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;ビルド&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;Github(or Bitbucket)のコードからアプリケーションをビルドします。&lt;/li&gt;
      &lt;li&gt;コミットするたびにビルドしてくれる。(設定は.circle/config.yml に。後述します)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;テスト&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;コミットするたびにコンテナ(もしくはVM)を立ち上げテストを走らせてくれる。&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;デプロイ&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;本番環境にsshして〜のような手動作業がなくせる。&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;通知&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;ビルド、テスト結果の通知。問題にすばやく気づける。&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;circleciconfigyml-の書き方&quot;&gt;.circleci/config.yml の書き方&lt;/h2&gt;

&lt;p&gt;Githubリポジトリに&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.circleci/config.yml&lt;/code&gt;を配置することで実行してくれる。&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;jobs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;job1&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;docker&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;          &lt;span class=&quot;c1&quot;&gt;# machine(VM), macOS など選べるらしい&lt;/span&gt;
            &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# dockerの場合は、dockerイメージを指定&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;checkout&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;# CI環境上でGitリポジトリをコピー&lt;/span&gt;
            &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;...&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;# コマンドの実行&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;workflows&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;               &lt;span class=&quot;c1&quot;&gt;# ジョブのパイプライン設定&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;jobs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;job1&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;初期設定としてCircleCIの管理画面でAdd Projectが必要&lt;/li&gt;
  &lt;li&gt;CircleCI version 1 系は circle.yml に記載していた。（が、ymlが version 2 系で書かれていれば動作する模様）
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://discuss.circleci.com/t/whats-the-difference-between-circleci-folder-and-circle-yml/13651&quot;&gt;https://discuss.circleci.com/t/whats-the-difference-between-circleci-folder-and-circle-yml/13651&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://circleci.com/docs/ja/2.0/configuration-reference/&quot;&gt;https://circleci.com/docs/ja/2.0/configuration-reference/&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;注 : CircleCI 1.0 から利用していたユーザーは、新たにconfig.yml ファイルを使うことで、以前とは異なるブランチで 2.x 環境におけるビルドを試すことができます。
従来の circle.yml の設定内容は残るため、.circleci/config.yml のないブランチである CircleCI 1.0 環境の実行にも支障はありません。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;※ version 1 系は 2018.8.31 で提供終了している &lt;a href=&quot;https://circleci.com/blog/sunsetting-1-0/&quot;&gt;https://circleci.com/blog/sunsetting-1-0/&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;workflowsで使いたい設定&quot;&gt;workflowsで使いたい設定&lt;/h2&gt;

&lt;h3 id=&quot;requires&quot;&gt;requires&lt;/h3&gt;

&lt;p&gt;ジョブの依存関係を設定できる。&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;jobs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;build&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;requires&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;build&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;※ ジョブ間のコンテナは別なのでデータの同期などは &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;save_caches&lt;/code&gt; などの設定が必要&lt;/p&gt;

&lt;h3 id=&quot;filtersonly-ignore&quot;&gt;filters(only, ignore)&lt;/h3&gt;

&lt;p&gt;実行するジョブをブランチ絞ってくれる&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;filters&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;deplyToProduction&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;only&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;master&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# masterブランチでのみ実施&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;deplyToDevelopment&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;only&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;develop&lt;/span&gt;       &lt;span class=&quot;c1&quot;&gt;# developブランチのみ&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;deplyToExperimental&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ignore&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;master&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# masterブランチは無視&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;triggers&quot;&gt;triggers&lt;/h3&gt;

&lt;p&gt;スケジューリングして動かす。&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;nightly&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;triggers&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;schedule&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;cron&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;*&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;local-cliの利用&quot;&gt;local CLIの利用&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://circleci.com/docs/2.0/local-cli/&quot;&gt;https://circleci.com/docs/2.0/local-cli/&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;install&quot;&gt;install&lt;/h3&gt;

&lt;p&gt;ローカルで以下を実行。ダウンロードからインストールまで。&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;curl &lt;span class=&quot;nt&quot;&gt;-fLSs&lt;/span&gt; https://circle.ci/cli | bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;ymlファイルの検証&quot;&gt;ymlファイルの検証&lt;/h3&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;circleci config validate &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; circle.yml
Error: Unable to parse YAML
&lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;parsing a block mapping
 &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'string'&lt;/span&gt;, line 1, column 1:
    version:
    ^
expected &amp;lt;block end&amp;gt;, but found &lt;span class=&quot;s1&quot;&gt;'-'&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'string'&lt;/span&gt;, line 2, column 1:
    -
    ^
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;ローカル環境dockerでのジョブの実行&quot;&gt;ローカル環境（docker）でのジョブの実行&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ circleci local execute --job JOB_NAME
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;環境変数は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-e HOST=xxx -e PASS=yyy&lt;/code&gt;  で設定できる&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;まとめと蛇足&quot;&gt;まとめと蛇足&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;CircleCIは開発プロセスの自動化の仕組みを提供してくれている&lt;/li&gt;
  &lt;li&gt;新しいプロジェクトにアサインされたときは、まずリポジトリの &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.circleci/config.yml&lt;/code&gt; を見つけたらまずそこから読むと追いやすいかも&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://circleci.com/product/&quot;&gt;https://circleci.com/product/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.redhat.com/ja/topics/devops/what-is-ci-cd&quot;&gt;https://www.redhat.com/ja/topics/devops/what-is-ci-cd&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Continuous_integration&quot;&gt;https://en.wikipedia.org/wiki/Continuous_integration&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://circleci.com/docs/2.0/getting-started/&quot;&gt;https://circleci.com/docs/2.0/getting-started/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sue445.hatenablog.com/entry/2018/12/07/114638&quot;&gt;https://sue445.hatenablog.com/entry/2018/12/07/114638&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.slant.co/versus/2482/16890/~gitlab-ci_vs_bitbucket-pipelines&quot;&gt;https://www.slant.co/versus/2482/16890/~gitlab-ci_vs_bitbucket-pipelines&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;補足&quot;&gt;補足&lt;/h2&gt;

&lt;h3 id=&quot;ci機能を提供するサービス&quot;&gt;CI機能を提供するサービス&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;CircleCI &lt;a href=&quot;https://circleci.com/product/&quot;&gt;https://circleci.com/product/&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;iOSのビルドできる！&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;TravisCI &lt;a href=&quot;https://travis-ci.com/&quot;&gt;https://travis-ci.com/&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;CircleCIよりも設定ファイルの記述量が抑えられるらしい。&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Weacker &lt;a href=&quot;https://www.oracle.com/corporate/acquisitions/wercker/&quot;&gt;https://www.oracle.com/corporate/acquisitions/wercker/&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;Werckerは1リポジトリ1 Dockerイメージ(CircleCIは1ジョブ1イメージにできる)&lt;/li&gt;
      &lt;li&gt;スケジューラはない&lt;/li&gt;
      &lt;li&gt;oracleに買収されてた。。&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Gitlab CI &lt;a href=&quot;https://docs.gitlab.com/ee/ci/&quot;&gt;https://docs.gitlab.com/ee/ci/&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;Gitlabと連携しやすい（あたりまえか&lt;/li&gt;
      &lt;li&gt;Merge When Pipeline Succeeds 便利&lt;/li&gt;
      &lt;li&gt;CIの実行(Runner)を自前で用意できる。（ローカルMacでiOSビルドとか&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Bitbucket Pipeline &lt;a href=&quot;https://www.atlassian.com/ja/software/bitbucket/features/pipelines&quot;&gt;https://www.atlassian.com/ja/software/bitbucket/features/pipelines&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;atlassianなので、Jiraとの連携もよいらしい。&lt;/li&gt;
      &lt;li&gt;freeだと 時間制限 50min/month&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

</description>
      <pubDate>Mon, 03 Aug 2020 00:00:00 +0000</pubDate>
      <link>https://web-u-project.com/tech/2020/08/03/circleci-first-step.html</link>
      <guid isPermaLink="true">https://web-u-project.com/tech/2020/08/03/circleci-first-step.html</guid>
    </item>
    
    
    
    
    
    
    
    
    
    <item>
      <title>google client api for python 使い方メモ</title>
      <description>&lt;p&gt;毎度書き方を忘れるのでまとめたいのですが、ひとまず以前の自分の書いたコードだったり
参考にしたリンクを載せておきます。&lt;/p&gt;

&lt;p&gt;思い出したり、他にコードを見つけたら追記していくかも。&lt;/p&gt;

&lt;h1 id=&quot;事前準備&quot;&gt;事前準備&lt;/h1&gt;

&lt;h2 id=&quot;サービスアカウントのキーファイルの作成&quot;&gt;サービスアカウントのキーファイルの作成&lt;/h2&gt;

&lt;p&gt;OAuth用の認証キー(サービスアカウントキー)を用意する。
jsonファイルの例（一部マスクしてあります）&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot; data-lang=&quot;json&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;service_account&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;project_id&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;＜プロジェクト名＞&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;private_key_id&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;****&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;private_key&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-----BEGIN PRIVATE KEY-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; 〜  &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;-----END PRIVATE KEY-----&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;client_email&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;****@****.iam.gserviceaccount.com&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;client_id&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;****&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;auth_uri&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://accounts.google.com/o/oauth2/auth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;token_uri&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://oauth2.googleapis.com/token&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;auth_provider_x509_cert_url&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://www.googleapis.com/oauth2/v1/certs&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;client_x509_cert_url&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://www.googleapis.com/〜.iam.gserviceaccount.com&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;※ 秘密鍵となるので、管理に気をつけましょう。
外部に漏れてしまった場合はGCPのコンソールから無効化すること。&lt;/p&gt;

&lt;h2 id=&quot;ライブラリのインストール&quot;&gt;ライブラリのインストール&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;pip &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--upgrade&lt;/span&gt; google-api-python-client google-auth-oauthlib&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h1 id=&quot;googledrive&quot;&gt;GoogleDrive&lt;/h1&gt;

&lt;h2 id=&quot;認証用メソッド&quot;&gt;認証用メソッド&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# get_drive_service.py
&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;json&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;os&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pickle&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;google.auth.transport.requests&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Request&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;google_auth_oauthlib.flow&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InstalledAppFlow&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;googleapiclient.discovery&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;build&lt;/span&gt;


&lt;span class=&quot;n&quot;&gt;DRIVE_SCOPES&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'https://www.googleapis.com/auth/drive'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;DRIVE_API_SERVICE_NAME&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'drive'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;DRIVE_API_VERSION&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'v3'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CREDENTIALS_DRIVE_PICKLE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;drive_credentials.pickle&quot;&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_drive_service&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;get_authenticated_service&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;DRIVE_API_SERVICE_NAME&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;DRIVE_API_VERSION&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pickle_file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CREDENTIALS_DRIVE_PICKLE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;scopes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DRIVE_SCOPES&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_authenticated_service&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;api_service_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                              &lt;span class=&quot;n&quot;&gt;api_version&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                              &lt;span class=&quot;n&quot;&gt;pickle_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                              &lt;span class=&quot;n&quot;&gt;scopes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SCOPES&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;pickle_path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;%s/%s&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CREDENTIALS_CACHE_DIR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pickle_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;get_pickled_credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pickle_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;[%s] credential expiry(old): %s&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pickle_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expiry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;req&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;refresh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;[%s] credential expiry(new): %s&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pickle_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expiry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pickle_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;wb&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;pickle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dump&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;api_service_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;api_version&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;info_str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;environ&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;GOOGLE_SERVICE_ACCOUNT&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;info_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;EnvironmentError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Cannnot found env.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;info&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loads&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;flow&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;InstalledAppFlow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;from_client_config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;scopes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scopes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;flow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run_console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pickle_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;wb&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pickle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dump&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;api_service_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;api_version&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;gdrive上にフォルダを作成する&quot;&gt;GDrive上にフォルダを作成する&lt;/h2&gt;

&lt;p&gt;mimeType: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;application/vnd.google-apps.folder&lt;/code&gt; にする&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;create_folder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;drive_service&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;parent_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;file_metadata&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;'mimeType'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'application/vnd.google-apps.folder'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;'parents'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parent_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;drive_service&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;files&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file_metadata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;file&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;csvファイルをspreadsheetとしてuploadする&quot;&gt;csvファイルをspreadsheetとしてuploadする&lt;/h2&gt;

&lt;p&gt;MediaIoBaseUpload の mimetypeは &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;text/csv&lt;/code&gt; 、
bodyパラメタのmimeTypeは &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;application/vnd.google-apps.spreadsheet&lt;/code&gt; にする&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;io&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;googleapiclient.http&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MediaIoBaseUpload&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;upload_csv_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;drive_service&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csv_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;parent_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;fh&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BytesIO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;csv_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;media&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MediaIoBaseUpload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mimetype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'text/csv'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;&quot;parents&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parent_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;'mimeType'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'application/vnd.google-apps.spreadsheet'&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;drive_service&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;files&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;media_body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;media&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;ファイルを参照する&quot;&gt;ファイルを参照する&lt;/h2&gt;

&lt;p&gt;（みつけたら書きます。）&lt;/p&gt;

&lt;h1 id=&quot;youtube-情報の取得-data-api-report-api&quot;&gt;Youtube 情報の取得 (Data API, Report API)&lt;/h1&gt;

&lt;p&gt;（みつけたら書きます）&lt;/p&gt;

&lt;h1 id=&quot;google-cloud-storage-バケットへテキストファイルをアップロードする&quot;&gt;Google Cloud Storage バケットへテキストファイルをアップロードする&lt;/h1&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;google.cloud&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storage&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;google.oauth2&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;service_account&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;GOOGLE_CLOUD_STORAGE_SCOPE_READWRITE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;https://www.googleapis.com/auth/devstorage.read_write&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;GSERVICEACCOUNT_FILEPATH&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;./config/gcp/service-account-sample.json&quot;&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_storage_client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;environ&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;GOOGLE_APPLICATION_CREDENTIALS&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GSERVICEACCOUNT_FILEPATH&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;service_account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;from_service_account_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;GSERVICEACCOUNT_FILEPATH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;scopes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GOOGLE_CLOUD_STORAGE_SCOPE_READWRITE&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;upload_text_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;content_type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text/plain&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;bucket&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bucket&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GCS_BUCKET_NAME&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;blob&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bucket&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;blob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;upload_from_string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;file_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;content_type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;content_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;__main__&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;get_storage_client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;upload_text_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;this is test text&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;sample.txt&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h1 id=&quot;refs&quot;&gt;refs.&lt;/h1&gt;

&lt;p&gt;google auth&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://google-auth.readthedocs.io/en/latest/user-guide.html&quot;&gt;https://google-auth.readthedocs.io/en/latest/user-guide.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cloud IAMについて&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://cloud.google.com/iam/docs/overview?hl=ja&quot;&gt;https://cloud.google.com/iam/docs/overview?hl=ja&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;サービスアカウントについて&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://cloud.google.com/iam/docs/understanding-service-accounts?hl=ja&quot;&gt;https://cloud.google.com/iam/docs/understanding-service-accounts?hl=ja&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;以前はサンプルコードがあったと思うのだけど、githubにredirectされてしまう。&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://developers.google.com/api-client-library/&quot;&gt;https://developers.google.com/api-client-library/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Python Quickstart  |  Sheets API  |  Google Developers&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://developers.google.com/sheets/api/quickstart/python&quot;&gt;https://developers.google.com/sheets/api/quickstart/python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Youtube API code sample&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://developers.google.com/youtube/v3/code_samples/python?hl=ja&quot;&gt;https://developers.google.com/youtube/v3/code_samples/python?hl=ja&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PyDoc for Drive API&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://developers.google.com/resources/api-libraries/documentation/drive/v2/python/latest/&quot;&gt;https://developers.google.com/resources/api-libraries/documentation/drive/v2/python/latest/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;便利/参考になるライブラリ&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;PyDrive &lt;a href=&quot;https://github.com/gsuitedevs/PyDrive&quot;&gt;https://github.com/gsuitedevs/PyDrive&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;BigQuery-Python &lt;a href=&quot;https://github.com/tylertreat/BigQuery-Python&quot;&gt;https://github.com/tylertreat/BigQuery-Python&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <pubDate>Wed, 12 Jun 2019 00:00:00 +0000</pubDate>
      <link>https://web-u-project.com/tech/2019/06/12/google_api_client_for_python.html</link>
      <guid isPermaLink="true">https://web-u-project.com/tech/2019/06/12/google_api_client_for_python.html</guid>
    </item>
    
    
    
    <item>
      <title>スライド資料をmarkdownで書ける remark.js を試しました。</title>
      <description>&lt;p&gt;&lt;a href=&quot;/use-remarkjs-on-jekeyll/&quot;&gt;スライド資料をmarkdownで書ける remark.js を試しました。&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Jekyll側では&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;post.layout == 'presentation'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;の投稿についてはtopとrssには含めないようにしてみました。&lt;/p&gt;

&lt;p&gt;feed.xmlは以下のような感じ&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;---
layout: null
---
&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;rss&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;version=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2.0&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:atom=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/2005/Atom&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;channel&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;{{ site.title }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;description&amp;gt;&lt;/span&gt;{{ site.description }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;link&amp;gt;&lt;/span&gt;{{ site.BASE_PATH }}/&lt;span class=&quot;nt&quot;&gt;&amp;lt;/link&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;atom:link&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;href=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;{{ site.BASE_PATH }}/{{ site.rss_path }}&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;rel=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;self&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;application/rss+xml&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    {% for post in site.posts limit:10 %}
    {% if post.layout == &quot;presentation&quot; %}
    {% else %}
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;item&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;{{ post.title }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;description&amp;gt;&lt;/span&gt;{{ post.content | xml_escape }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;pubDate&amp;gt;&lt;/span&gt;{{ post.date | date: &quot;%a, %d %b %Y %H:%M:%S %z&quot; }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/pubDate&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;link&amp;gt;&lt;/span&gt;{{ site.BASE_PATH }}{{ post.url }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/link&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;guid&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;isPermaLink=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;{{ site.BASE_PATH }}{{ post.url }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/guid&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
    {% endif %}
    {% endfor %}
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/channel&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/rss&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</description>
      <pubDate>Mon, 13 May 2019 00:00:00 +0000</pubDate>
      <link>https://web-u-project.com/tech/2019/05/13/remark_on_jekeyll.html</link>
      <guid isPermaLink="true">https://web-u-project.com/tech/2019/05/13/remark_on_jekeyll.html</guid>
    </item>
    
    
    
    
    
    
    <item>
      <title>「全員発表型！ コーポレートエンジニアリングLT大会」に参加してきました。</title>
      <description>&lt;p&gt;最近は複数の案件をいただき仕事をしています。&lt;/p&gt;

&lt;p&gt;ほとんどがデータ解析だったり、分析基盤のインフラ系の仕事なのですが、毛色の違う案件で 知人の紹介でスタートアップの情シスとして週2くらいで働いています。&lt;/p&gt;

&lt;p&gt;発表資料はその会社でやったことの一部を紹介させていただきました。 偶然イベントを見つけたので参加させていただきました。&lt;/p&gt;

&lt;p&gt;(情シス、社内エンジニアというような人たちの情報ってなかなかネットで見つからないですよね。。)&lt;/p&gt;

&lt;h2 id=&quot;参加したイベント&quot;&gt;参加したイベント&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;全員発表型！ コーポレートエンジニアリングLT大会
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.wantedly.com/projects/260148&quot;&gt;https://www.wantedly.com/projects/260148&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;発表資料&quot;&gt;発表資料&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://speakerdeck.com/u110/public-corp-eng-lt-20181204&quot;&gt;https://speakerdeck.com/u110/public-corp-eng-lt-20181204&lt;/a&gt;
&lt;script async=&quot;&quot; class=&quot;speakerdeck-embed&quot; data-id=&quot;86f76478b1d44178bf271247db597d98&quot; data-ratio=&quot;1.33333333333333&quot; src=&quot;//speakerdeck.com/assets/embed.js&quot;&gt;&lt;/script&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;常駐先のGSuiteの活用状況についてまとめました。&lt;/p&gt;

&lt;p&gt;GoogleDriveは便利なのですが、権限周りが鬼門という認識は参加者で一致しました。
また、GoogleDriveにはBusiness版以降のプランではチームドライブという機能があるのでそれを使いたいと考えています。&lt;/p&gt;

&lt;h2 id=&quot;学びのあった話のメモ&quot;&gt;学びのあった話のメモ&lt;/h2&gt;

&lt;h3 id=&quot;人数規模と自動化のタイミング&quot;&gt;人数規模と自動化のタイミング&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;組織変更に伴なうワークフローの承認順序の変更&lt;/li&gt;
  &lt;li&gt;退職、異動に伴なう権限の剥奪、移譲。&lt;/li&gt;
  &lt;li&gt;100人未満であれば人力でできるが、それ以上だと結構辛くなる&lt;/li&gt;
  &lt;li&gt;先付け（＝設定変更の事前予約）の仕組みを用意し、自動化の仕組みを用意している&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;paas系ツールの利用とアクセスコントロール&quot;&gt;PaaS系ツールの利用とアクセスコントロール&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;PaaS系ツールが増えて便利になった。&lt;/li&gt;
  &lt;li&gt;反面、管理側でフォローしきれない状態&lt;/li&gt;
  &lt;li&gt;SSOやパスワード管理ツールを利用して、IDの集約・管理をしている&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;その他&quot;&gt;その他&lt;/h2&gt;

&lt;p&gt;SlackはIDを自由に付けれる反面、本名しか知らない場合探しにくいという課題があります。&lt;/p&gt;

&lt;p&gt;参加者の会社ではhubotに本名からSlackIDやその他連絡方法を返してくれる機能を作ったとのこと。自分のところでも早速利用したいです。&lt;/p&gt;

&lt;p&gt;情シス業での学びは他の仕事でも活かしていきたい。&lt;/p&gt;
</description>
      <pubDate>Wed, 05 Dec 2018 00:00:00 +0000</pubDate>
      <link>https://web-u-project.com/tech/event/2018/12/05/corp-engineer-lt.html</link>
      <guid isPermaLink="true">https://web-u-project.com/tech/event/2018/12/05/corp-engineer-lt.html</guid>
    </item>
    
    
    
    <item>
      <title>最近の状況報告[2018年10月]</title>
      <description>&lt;p&gt;ココ最近の近況報告とこれからについてまとめてみました。
毎月書いていきたい。。。！&lt;/p&gt;

&lt;h2 id=&quot;お仕事&quot;&gt;お仕事&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;スタートアップ事業の業務フロー整理（情シス）
    &lt;ul&gt;
      &lt;li&gt;リスク管理まわり相談したいという話から。&lt;/li&gt;
      &lt;li&gt;Gsuite, LastPass, Slack, kibela あたりのサービスを整理、導入してみたり。&lt;/li&gt;
      &lt;li&gt;個人的にはデータ分析の相談ももらえてるのでそっち側にシフトできたらなと。&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;広告レポート集約管理システムの改修&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;その他&quot;&gt;その他&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;子育てエンジニアmeetupでLTしてきました。&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote class=&quot;twitter-tweet&quot; data-lang=&quot;ja&quot;&gt;&lt;p lang=&quot;ja&quot; dir=&quot;ltr&quot;&gt;丸二日たってしまいましたが発表資料載せました〜   &lt;a href=&quot;https://twitter.com/hashtag/%E5%AD%90%E8%82%B2%E3%81%A6%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%8B%E3%82%A2?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#子育てエンジニア&lt;/a&gt; &lt;a href=&quot;https://t.co/06e8PXXYSE&quot;&gt;https://t.co/06e8PXXYSE&lt;/a&gt; 懇親会も子育てトークできて楽しかったです。&lt;/p&gt;&amp;mdash; ゆう (@yuu_ito) &lt;a href=&quot;https://twitter.com/yuu_ito/status/1052533864160063488?ref_src=twsrc%5Etfw&quot;&gt;2018年10月17日&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;ul&gt;
  &lt;li&gt;Developersjp というコミュニティに参加しています。
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.developersjp.online/&quot;&gt;https://www.developersjp.online/&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;コミュニティ内徳丸本２版読み会を主催？（言い出しっぺ）させてもらっています。
        &lt;ul&gt;
          &lt;li&gt;一緒に勉強できる人いるのは嬉しい。&lt;/li&gt;
          &lt;li&gt;コミュニティにも貢献していきたい。&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;これから&quot;&gt;これから&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;新しいお仕事。
    &lt;ul&gt;
      &lt;li&gt;ネット広告系のインフラ業務。&lt;/li&gt;
      &lt;li&gt;↑と別で分類ロジック周りでシステム開発できるかも（ざっくりしすぎｗ&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;イベント
    &lt;ul&gt;
      &lt;li&gt;HPも個人プロジェクトでもFirebase使っているので
Firebase関連のイベントいきたいな。&lt;/li&gt;
      &lt;li&gt;地方移住紹介イベントに顔を出す。&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;保育園申請&lt;/li&gt;
  &lt;li&gt;確定申告にむけて整理していこう。。&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;その他-1&quot;&gt;その他&lt;/h1&gt;

&lt;h2 id=&quot;相棒macbookproの引退&quot;&gt;相棒MacBookProの引退&lt;/h2&gt;

&lt;p&gt;今まで現役で活躍してくれていた2010モデルのMacBookPro。&lt;/p&gt;

&lt;p&gt;電池が１０分も持たなくなってしまったので新しく購入。&lt;/p&gt;

&lt;p&gt;（LTの最中に落ちるという。。汗）&lt;/p&gt;

&lt;p&gt;前職の同期からお古としてもらったのを、ディスクを替え、メモリ増築したりと長生きさせてきたので感慨深い。&lt;/p&gt;

&lt;p&gt;今まで頑張ってくれてありがとう。&lt;/p&gt;

&lt;p&gt;これからはサブ機として余生を過ごしてもらおう。&lt;/p&gt;

&lt;p&gt;メモリが8G –&amp;gt; 16Gになり、&lt;/p&gt;

&lt;p&gt;アプリの起動がサクサク動くので素晴らしい。&lt;/p&gt;

&lt;h2 id=&quot;フリーランスとしての働き方&quot;&gt;フリーランスとしての働き方&lt;/h2&gt;

&lt;p&gt;前職を去年の11月に退職したので、そろそろ１年。&lt;/p&gt;

&lt;p&gt;とりあえず食っていけそうな気もする。。&lt;/p&gt;

&lt;p&gt;食ってはいけるが、働き方とかより稼ぐとなるといくつか課題を感じている。&lt;/p&gt;

&lt;p&gt;地方移住についても、いろんな方から話を伺うことができた。&lt;/p&gt;

&lt;p&gt;ちょっと話は違うけど、情シス業は本来やりたいこととは若干ズレてはいたが、いろいろと学びがあり、次のアクションに向けて良い経験になっている。&lt;/p&gt;

&lt;p&gt;これについては別途まとめていきたい。&lt;/p&gt;
</description>
      <pubDate>Mon, 22 Oct 2018 00:00:00 +0000</pubDate>
      <link>https://web-u-project.com/monthly/2018/10/22/201810_entry.html</link>
      <guid isPermaLink="true">https://web-u-project.com/monthly/2018/10/22/201810_entry.html</guid>
    </item>
    
    
    
    <item>
      <title>Amazon LinuxにeralchemyをインストールしてER図を作成</title>
      <description>&lt;ul&gt;
  &lt;li&gt;DBのテーブル構成を知りたい&lt;/li&gt;
  &lt;li&gt;ER図の生成にeralchemyを利用&lt;/li&gt;
  &lt;li&gt;PDFやマークダウンで出力できる&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; data-lang=&quot;ja&quot;&gt;&lt;p lang=&quot;ja&quot; dir=&quot;ltr&quot;&gt;psycopg2のよみは「さいこぴーじーつー」かな&lt;/p&gt;&amp;mdash; ゆう (@yuu_ito) &lt;a href=&quot;https://twitter.com/yuu_ito/status/989767425112424450?ref_src=twsrc%5Etfw&quot;&gt;2018年4月27日&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;最近ご一緒しているお仕事でPostgreSQLのテーブルを見る機会があったのですが、&lt;/p&gt;

&lt;p&gt;全体感を掴むためにひとまずER図を描きたいと思いました。&lt;/p&gt;

&lt;p&gt;調べたところ eralchemyというツールを見つけたので試してみます。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;eralchemy
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://github.com/Alexis-benoist/eralchemy&quot;&gt;https://github.com/Alexis-benoist/eralchemy&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;インストール&quot;&gt;インストール&lt;/h2&gt;

&lt;p&gt;AWSで管理しているのでRDSに繋げることができる&lt;/p&gt;

&lt;p&gt;amazonlinuxで動いているEC2にインスタンスしました。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;事前にpdf生成にgraphvizパッケージをインストールしておく&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;ec2-user: &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;graphviz graphviz-devel graphviz-gd graphviz-python27 graphviz-graphs&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;今回はPostgreSQL上のテーブルを参照したいのでPostgreSQL用のドライバを利用します。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;psqlコマンドでDB接続する際に設定した環境変数&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;ec2-user: &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; ~/.bash_profile
&lt;span class=&quot;c&quot;&gt;# .bash_profile&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Get the aliases and functions&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; ~/.bashrc &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
	&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; ~/.bashrc
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# User specific environment and startup programs&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;:&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/.local/bin:&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/bin

&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;PATH

&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PGHOST&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;xxxx.rds.amazonaws.com
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PGPORT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;5432
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PGDATABASE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;xxxx
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PGUSER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;xxxx
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PGPASSWORD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;xxxx&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;PDFを生成するコマンド&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;ec2-user: &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;generate_erd.sh
eralchemy &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;postgresql+psycopg2://&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PGUSER&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PGPASSWORD&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PGHOST&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PGPORT&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PGDATABASE&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; erd.pdf&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</description>
      <pubDate>Tue, 01 May 2018 00:00:00 +0000</pubDate>
      <link>https://web-u-project.com/tech/2018/05/01/eralchemy.html</link>
      <guid isPermaLink="true">https://web-u-project.com/tech/2018/05/01/eralchemy.html</guid>
    </item>
    
    
    
    <item>
      <title>Kaggle API のインストールとデータセットのダウンロード</title>
      <description>&lt;ul&gt;
  &lt;li&gt;Kaggle APIを使って分析環境の準備&lt;/li&gt;
  &lt;li&gt;データセットのダウンロード、予測結果のサブミットもできる&lt;/li&gt;
  &lt;li&gt;次回はtitanicデータを眺める&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;インストール&quot;&gt;インストール&lt;/h2&gt;

&lt;p&gt;Kaggle APIはコマンドラインツールです。&lt;/p&gt;

&lt;p&gt;pythonで実装されたツールなのでpipでインストールします。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;pip &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;kaggle&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;ヘルプ&quot;&gt;ヘルプ&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;kaggle &lt;span class=&quot;nt&quot;&gt;--help&lt;/span&gt;
Unauthorized: you must download an API key from https://www.kaggle.com/&amp;lt;username&amp;gt;/account
Then put kaggle.json &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;the folder /Users/u110/.kaggle&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;とりあえずhelpを見てみようとしたら上記のようなメッセージが。&lt;/p&gt;

&lt;p&gt;アカウントの認証が必要とのこと。&lt;/p&gt;

&lt;p&gt;ブラウザログインして、上で指定されているURLを開くとAPIという項目がありました。&lt;/p&gt;

&lt;p&gt;“Create New API Token” というボタンを押すと kaggle.json がダウンロードできるので、&lt;/p&gt;

&lt;p&gt;そのファイルを指定通りに ~/.kaggle ディレクトリ以下に配置します。&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ kaggle --help
Warning: Your Kaggle API key is readable by other users on this system! To fix this, you can run 'chmod 600 /Users/itouyuu/.kaggle/kaggle.json'
usage: kaggle [-h] {competitions,datasets,config} ...

optional arguments:
  -h, --help            show this help message and exit

commands:
  {competitions,datasets,config}
                        Use one of:
                        competitions {list, files, download, submit, submissions}
                        datasets {list, files, download, create, version, init}
                        config {view, set, unset}
    competitions        Commands related to Kaggle competitions
    datasets            Commands related to Kaggle datasets
    config              Configuration settings
$ chmod 600 ~/.kaggle/kaggle.json
$ kaggle datasets
usage: kaggle datasets [-h] {list,files,download,create,version,init} ...
kaggle datasets: error: the following arguments are required: command
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;コマンドのヘルプが出ましたね。&lt;/p&gt;

&lt;p&gt;chmodでパーミッション変えておいてねとあるのでやっておきましょう。&lt;/p&gt;

&lt;p&gt;親切。。！&lt;/p&gt;

&lt;h2 id=&quot;コンペの参照&quot;&gt;コンペの参照&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;kaggle competitions list
ref                                             deadline             category            reward  teamCount  userHasEntered  
&lt;span class=&quot;nt&quot;&gt;----------------------------------------------&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;-------------------&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;---------------&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;---------&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;---------&lt;/span&gt;  &lt;span class=&quot;nt&quot;&gt;--------------&lt;/span&gt;  
imagenet-object-detection-challenge             2029-12-31 07:00:00  Research         Knowledge          0           False  
imagenet-object-detection-from-video-challenge  2029-12-31 07:00:00  Research         Knowledge          0           False  
imagenet-object-localization-challenge          2029-12-31 07:00:00  Research         Knowledge          7           False  
titanic                                         2020-04-07 00:00:00  Getting Started  Knowledge      11053            True  
house-prices-advanced-regression-techniques     2020-03-01 23:59:00  Getting Started  Knowledge       5061           False  
digit-recognizer                                2020-01-07 00:00:00  Getting Started  Knowledge       2242           False  
...&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;データセットのダウンロード&quot;&gt;データセットのダウンロード&lt;/h2&gt;

&lt;p&gt;titanicデータをダウンロードしてみましょう。&lt;/p&gt;

&lt;p&gt;とりあえすdownloadコマンドのヘルプを叩いてみます。&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ kaggle competitions download --help
usage: kaggle competitions download [-h] [-c COMPETITION] [-f FILE] [-p PATH]
                                    [-w] [-o] [-q]

optional arguments:
  -h, --help            show this help message and exit
  -c COMPETITION, --competition COMPETITION
                        Competition URL suffix (use &quot;kaggle competitions list&quot; to show options)
                        If empty, the default competition will be used (use &quot;kaggle config set competition&quot;)&quot;
  -f FILE, --file FILE  File name, all files downloaded if not provided
                        (use &quot;kaggle competitions files -c &amp;lt;competition&amp;gt;&quot; to show options)
  -p PATH, --path PATH  Folder where file(s) will be downloaded, defaults to /Users/itouyuu/.kaggle
  -w, --wp              Download files to current working path
  -o, --force           Skip check whether local version of file is up to date, force file download
  -q, --quiet           Suppress printing information about download progress
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;cオプションでコンペ名を指定するようですね。&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ kaggle competitions download -c titanic
train.csv: Downloaded 60KB of 60KB
test.csv: Downloaded 28KB of 28KB
gender_submission.csv: Downloaded 3KB of 3KB
$ ls ~/.kaggle/
competitions/ kaggle.json
$ ls ~/.kaggle/competitions/titanic/
gender_submission.csv  test.csv               train.csv
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;APIトークンを配置した.kaggleディレクトリ以下にダウンロードされました。&lt;/p&gt;

&lt;p&gt;こんなツールあったの知りませんでした。&lt;/p&gt;

&lt;p&gt;次回はtitanicデータを眺めて何かしらやってみます。&lt;/p&gt;

&lt;h2 id=&quot;参考&quot;&gt;参考&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;(https://github.com/Kaggle/kaggle-api)[https://github.com/Kaggle/kaggle-api]&lt;/li&gt;
&lt;/ul&gt;
</description>
      <pubDate>Tue, 17 Apr 2018 00:00:00 +0000</pubDate>
      <link>https://web-u-project.com/tech/2018/04/17/kaggle_api.html</link>
      <guid isPermaLink="true">https://web-u-project.com/tech/2018/04/17/kaggle_api.html</guid>
    </item>
    
    
  </channel>
</rss>
