codingecho

日々の体験などを書いてます

Python

PythonでgRPCのリクエストをする

PythonでgRPCを扱う方法です。クライアント側だけの紹介です。 Protocol Buffersの定義ファイルを用意します。 crawl.proto syntax = 'proto3'; package proto; service Crawler { rpc Crawl(CrawlRequest) returns (CrawlResponse); } message CrawlRequest…

Pythonで文字列に絵文字と半角カタカナが含まれているか判定する

ここではPython 3.7を使った方法を紹介します。 絵文字の判定 現時点の最新版であるUnicode® Emoji Charts v11.0では、絵文字のUnicodeは1F600から1F3F4の範囲でコードが振られています。 なので、Unicodeの範囲を指定すればいけるじゃんと思っていたのです…

Apache Beamで自作パッケージを使う方法

Cloud Dataflow pipeline上で自作パッケージを使う場合は setup.py を作成して --setup-file オプションで指定しなければなりません。 以下のようなディレクトリ構成で main.py が my-package に依存していたとします。 Dataflow |- my-package/ |- helper.p…

Google Cloud Dataflow上でReadFromDatastoreを使わずにCloud Datastoreからデータを取得する

TL;DR google-cloud-datastoreの代わりにCloud Datastore’s helper methodを使用する。 より詳しく Apache Beam pipelineのインスタンスを作る直前にCloud Datastoreからデータを取得したいと思い ReadFromDatastore を Cloud Dataflow上のapache_beam.io.gc…

Run Apache Beam process with local dependency

If you run Cloud Dataflow pipeline with some your local package, you must create setup.py and specify --setup-file option. Assume that you have a directory structure like below and main.py depends on under the my-package packages. Dataflow…

Read data from Google Cloud Datastore without ReadFromDatastore On Google Cloud Dataflow

TL;DR Use Cloud Datastore's helper method instead of google-cloud-datastore. More Details I wanted to read data from Datastore before running an Apache Beam's pipeline that uses ReadFromDatastore from apache_beam.io.gcp.datastore.v1.datast…

Rotation and shear mapping of Linear algebra

I created simple examples of the rotation and shear mapping of linear algebra for understanding. My examples this repository. This visualized example was very helpful for understanding eigenvectors and eigenvalues. Rotation The rotation us…