EvidenceによるBI入門 #002

基本的な準備 システム構成の概要 Evidenceのアーキテクチャ Evidenceは基本的には、データソース、DuckDB、レンダリングエンジンという仕組みになっています。実際には更に、 静的サイトジェネレータも重要な位置を示しますが、その性質からここには表現していません。以下の図にEvidenceの基本的なアーキテクチャを示します。 まず、データソースからデータが取り出され、共通のデータ形式であるParquetに変換されます。ParquetはDuckDBによって利用されます。 従って、Evidenceで利用可能なデータは基本的にParquetに抽出されたデータに限定されます。 よって、標準的なBIツールのようにOn the flyのクエリを動的に送出してリアルタイムなデータを反映させることは出来ません。 従って、そのような要件が含まれる場合にはEvidenceは適切な選択肢ではありません。 従って、ドキュメントの流れまで含めて、アーキテクチャを図示すると以下のような形になります。 動作環境 Evidenceを動作させるためには、以下の環境が必要です。 Node.js: バージョン ≥18.13, 20, または 22 が必要です。初めてインストールする場合は、LTS(長期サポート)バージョンの利用が推奨されています。現在のNode.jsのバージョンはコマンド node -v で確認できます。 NPM (Node Package Manager): バージョン 7 以上が必要です。 Git: Gitがインストールされている必要があります。Gitがインストールされていない場合は、インストールする必要があります。GitHubへの登録も推奨されています。 これらの要件を満たすことで、Evidenceをローカル環境にインストールし、データプロダクトの構築を開始することができます。 現在のNode.jsのバージョンの確認方法 node -v 最新のNode.jsへの更新方法 scoop update nodejs-lts npmのバージョン確認方法 npm -v gitのインストール方法 scoop install git Evidenceのインストール方法 Evidenceには幾つかのインストールパターンがありますが、ダッシュボード開発時にはVisual Studio Codeと専用の拡張機能の利用が推奨されます。 本アーティクルでは、基本的にはScoopで環境構築を行っています。 scoopがインストールされている場合は以下のコマンドでnode.jsやNPMを展開できます。 scoopを利用することで、バージョンの管理、アップデートは容易になります。 scoop install nodejs-lts なお、本アーティクル以降ではVisual Studio Codeでの構築を行っていきますので、Visual Studio CodeにEvidenceの拡張機能を導入してください。 また、これらのインストール中にエラーが生じた場合には、そのステップに応じて、ScoopやVisual Studio Code、Evidenceのドキュメントを参照してください。 システム構成の概要 ダッシュボード開発時の典型的な構成は以下のようになります。 ...

3月 20, 2025 · 1 分 · 87 文字 · Me

EvidenceによるBI入門 #002.5

今回はちょっとだけ箸休め的にScoopによる環境構築を多少補足します。 本シリーズでは基本的には、環境構築はScoopを用いることを前提としています。 Scoopはコマンド一つで様々なパッケージを展開可能なツールです。 Scoopは悪い意味ではまっとうなパッケージマネージャではありません。しかし、以下の条件の元では極めて有効に働きます。 You’re a programmer/developer You want to set up a machine without having to visit a bunch of websites, download installers and then click through each one You’re comfortable working on the command line, especially with tools like Git You’re familiar with UNIX tools, and you wish there were more of them on Windows You read Hacker News and you feel like you’re ‘stuck’ on Windows and missing out on lots of cool things You wish there was an easier way to tell other developers how to install programs (maybe your own programs) You use Homebrew/apt-get and think, “this is awesome”. https://github.com/ScoopInstaller/Scoop/wiki/So-What より。 ...

3月 20, 2025 · 1 分 · 162 文字 · Me

BLOGリニューアル

BLOGのテーマを入れ替えて、再構築しました。 前のHugo Bootstrap Premiumが今のHugoでは古すぎるので。

3月 18, 2025 · 1 分 · 4 文字 · Me

SingularityのWSL2への構築

SingularityコンテナをWSL2上に構築しました。構築環境はSingularityの公式サイトの記述に基づき、Ubuntu 22.04上とします。 参考となるドキュメントは https://docs.sylabs.io/guides/latest/admin-guide/installation.html#installation-on-windows-or-mac に存在します。このドキュメントに従えば、Singularity 4.0.0がインストールされます。 手順としては以下の通りになります。 wget https://github.com/sylabs/singularity/releases/download/v4.0.0/singularity-ce_4.0.0-jammy_amd64.deb sudo apt install ./singularity-ce_4.0.0-jammy_amd64.deb まず、Singularity 4.0.0のUbuntu 22.04用のdebファイルを取得します。しかる後に、debファイルをaptコマンドでインストールします。当方で実行したときにはいくつか気になるメッセージが出力されていましたがインストール自体は行われているようです。以下のメッセージの表示理由等は未解明です。 N: Download is performed unsandboxed as root as file ‘/home/gorn/singularity-ce_4.0.0-jammy_amd64.deb’ couldn’t be accessed by user ‘_apt’. - pkgAcquire::Run (13: Permission denied) さて、Singularityがインストールできたので確認してみます。 以下のファイルをex001.defとして作成します。 Bootstrap: docker From: ubuntu:22.04 %post apt-get -y update apt-get -y upgrade %runscript echo "Hello, Ubuntu" 以下のコマンドでビルドします。 singularity build ubuntu.sif ex001.def Ubuntu 22.04のイメージとなります。 Shellでコンテナの中に入ってみます。 singularity shell ubuntu.sif とりあえず、動きは確認できました。

12月 19, 2023 · 1 分 · 66 文字 · Me

RinnaStableDiffusion

Rinnaから日本語対応のStable Diffusionが出たのでをGoogle Colab上で使ってみました。 コードとしては以下のような形です。bashのコードはJupyterから投げます。 pip install gradio try: from japanese_stable_diffusion import JapaneseStableDiffusionPipeline except: res = subprocess.run(['pip', 'install', 'git+https://github.com/rinnakk/japanese-stable-diffusion'], stdout=subprocess.PIPE).stdout.decode('utf-8') print(res) from japanese_stable_diffusion import JapaneseStableDiffusionPipeline import torch from torch import autocast from diffusers import LMSDiscreteScheduler from PIL import Image from IPython import display import gradio as gr def make_grid_from_pils(pil_images): w, h = pil_images[0].size grid_img = Image.new("RGB", ((len(pil_images)) * w, h)) for idx, image in enumerate(pil_images): grid_img.paste(image, (idx * w, 0)) return grid_img from huggingface_hub import notebook_login notebook_login() model_id = "rinna/japanese-stable-diffusion" device = "cuda" if torch.cuda.is_available() else "cpu" # Use the K-LMS scheduler here instead scheduler = LMSDiscreteScheduler( beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000 ) pipe = JapaneseStableDiffusionPipeline.from_pretrained( pretrained_model_name_or_path=model_id, scheduler=scheduler, torch_dtype=torch.float16, use_auth_token=True ).to(device) #@markdown ###**Inference Setting:** # the number of output images. If you encounter Out Of Memory error, decrease this number. n_samples = 1 #@param{type: 'integer'} # `classifier-free guidance scale` adjusts how much the image will be like your prompt. Higher values keep your image closer to your prompt. guidance_scale = 7.5 #@param {type:"number"} # How many steps to spend generating (diffusing) your image. steps = 50 #@param{type: 'integer'} # The width of the generated image. width = 512 #@param{type: 'integer'} # The height of the generated image. height = 512 #@param{type: 'integer'} # The seed used to generate your image. Enable to manually set a seed. seed = 'random' #@param{type: 'string'} import torch from torch import autocast from diffusers import LMSDiscreteScheduler from japanese_stable_diffusion import JapaneseStableDiffusionPipeline model_id = "rinna/japanese-stable-diffusion" device = "cuda" # Use the K-LMS scheduler here instead scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000) pipe = JapaneseStableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, use_auth_token=True) pipe = pipe.to(device) prompt = "富士山をバックに二大スーパーロボットががっちりと握手" with autocast("cuda"): image = pipe(prompt, guidance_scale=7.5)["sample"][0] image.save("output.png") image “富士山をバックに二大スーパーロボットががっちりと握手"から画像を作成し、以下のような画像になります。 ...

9月 9, 2022 · 2 分 · 272 文字 · Me