Skip to content
Merged

1.7.0 #187

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7fa50d6
initial commit
digitalghost-dev Sep 20, 2025
78aa96d
updating dependencies
digitalghost-dev Sep 20, 2025
2ae9740
sorting imports
digitalghost-dev Sep 21, 2025
a833181
sorting imports
digitalghost-dev Sep 21, 2025
67ae053
initial table and selection result (#186)
digitalghost-dev Sep 22, 2025
a899b05
updating comments (#186)
digitalghost-dev Sep 22, 2025
7dc679e
creating row level security macro
digitalghost-dev Sep 23, 2025
c29a2a4
initial relationship modeling macro
digitalghost-dev Sep 23, 2025
27a5f55
initial dbt project structure
digitalghost-dev Sep 23, 2025
d62c468
adding berry struct (#186)
digitalghost-dev Sep 23, 2025
4c54cbb
simplify dbt dagster integration
digitalghost-dev Sep 23, 2025
1fe752d
adding second screen using BerryInfo() (#186)
digitalghost-dev Sep 23, 2025
1a449a3
adding more information on sources
digitalghost-dev Sep 23, 2025
aaae817
adding post-hook macro
digitalghost-dev Sep 24, 2025
14d166c
updating env variable names
digitalghost-dev Sep 24, 2025
5c76347
initial commit
digitalghost-dev Sep 24, 2025
33718df
editing function to be more generic and accept any number of args (#186)
digitalghost-dev Sep 24, 2025
ee070f6
adding additional functions for printing berry info (#186)
digitalghost-dev Sep 25, 2025
419fc3c
updating tests
digitalghost-dev Sep 25, 2025
3b097b7
adding berry image (#186)
digitalghost-dev Sep 25, 2025
6b11bc2
updating file name
digitalghost-dev Sep 25, 2025
f71d38c
initial test files (#186)
digitalghost-dev Sep 25, 2025
2dd37c2
updating version numbers
digitalghost-dev Sep 25, 2025
c7549dc
updating dependencies
digitalghost-dev Sep 25, 2025
dc7b9a5
updating version numbers
digitalghost-dev Sep 25, 2025
ebf7a6d
updating paths to ignore
digitalghost-dev Sep 25, 2025
e36e075
initial database files
digitalghost-dev Sep 25, 2025
3282d05
updating data
digitalghost-dev Sep 26, 2025
7b3fcdb
updating info for IAM and RDS
digitalghost-dev Sep 26, 2025
8afb442
updating info
digitalghost-dev Sep 26, 2025
1c96def
implementing QueryBerryData() and adding more berry details (#186)
digitalghost-dev Sep 26, 2025
9d42a2d
updating test data
digitalghost-dev Sep 26, 2025
a0dba5f
adding berry command reference (#186)
digitalghost-dev Sep 26, 2025
a6aa967
adding berry command call (#186)
digitalghost-dev Sep 26, 2025
d92afab
initial commit
digitalghost-dev Sep 26, 2025
9941079
updating title
digitalghost-dev Sep 26, 2025
1556ecb
initial commit with post-hook
digitalghost-dev Sep 26, 2025
05dd553
fixing golangci-lint errors
digitalghost-dev Sep 26, 2025
89b1ef5
adding better error handling to reading/opening db file (#186)
digitalghost-dev Sep 26, 2025
bf071ee
updating dependencies
digitalghost-dev Sep 26, 2025
d23c6a8
rewording sentences
digitalghost-dev Sep 27, 2025
7001ca3
initial tests
digitalghost-dev Sep 27, 2025
6f85f4f
updating formatting and comments
digitalghost-dev Sep 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ on:
- main

env:
VERSION_NUMBER: 'v1.6.2'
VERSION_NUMBER: 'v1.7.0'
DOCKERHUB_REGISTRY_NAME: 'digitalghostdev/poke-cli'
AWS_REGION: 'us-west-2'

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ card_data/.tmp*/**

card_data/pipelines/poke_cli_dbt/.user.yml
/card_data/supabase/

card_data/~/
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ builds:
- windows
- darwin
ldflags:
- -s -w -X main.version=v1.6.2
- -s -w -X main.version=v1.7.0

archives:
- formats: [ 'zip' ]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN go mod download

COPY . .

RUN go build -ldflags "-X main.version=v1.6.2" -o poke-cli .
RUN go build -ldflags "-X main.version=v1.7.0" -o poke-cli .

# build 2
FROM --platform=$BUILDPLATFORM alpine:3.22
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img height="250" width="350" src="pokemon.svg" alt="pokemon-logo"/>
<h1>Pokémon CLI</h1>
<img src="https://img.shields.io/github/v/release/digitalghost-dev/poke-cli?style=flat-square&logo=git&logoColor=FFCC00&label=Release%20Version&labelColor=EEE&color=FFCC00" alt="version-label">
<img src="https://img.shields.io/docker/image-size/digitalghostdev/poke-cli/v1.6.2?arch=arm64&style=flat-square&logo=docker&logoColor=FFCC00&labelColor=EEE&color=FFCC00" alt="docker-image-size">
<img src="https://img.shields.io/docker/image-size/digitalghostdev/poke-cli/v1.7.0?arch=arm64&style=flat-square&logo=docker&logoColor=FFCC00&labelColor=EEE&color=FFCC00" alt="docker-image-size">
<img src="https://img.shields.io/github/actions/workflow/status/digitalghost-dev/poke-cli/ci.yml?branch=main&style=flat-square&logo=github&logoColor=FFCC00&label=CI&labelColor=EEE&color=FFCC00" alt="ci-status-badge">
</div>
<div align="center">
Expand Down Expand Up @@ -91,11 +91,11 @@ Cloudsmith is a fully cloud-based service that lets you easily create, store, an
3. Choose how to interact with the container:
* Run a single command and exit:
```bash
docker run --rm -it digitalghostdev/poke-cli:v1.6.2 <command> [subcommand] flag]
docker run --rm -it digitalghostdev/poke-cli:v1.7.0 <command> [subcommand] flag]
```
* Enter the container and use its shell:
```bash
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.6.2 -c "cd /app && exec sh"
docker run --rm -it --name poke-cli --entrypoint /bin/sh digitalghostdev/poke-cli:v1.7.0 -c "cd /app && exec sh"
# placed into the /app directory, run the program with './poke-cli'
# example: ./poke-cli ability swift-swim
```
Expand Down Expand Up @@ -158,6 +158,7 @@ By running `poke-cli [-h | --help]`, it'll display information on how to use the
│ │
│ COMMANDS: │
│ ability Get details about an ability │
│ berry Get details about a berry │
│ item Get details about an item │
│ move Get details about a move │
│ natures Get details about all natures │
Expand All @@ -182,7 +183,7 @@ Below is a list of the planned/completed commands and flags:

- [x] `ability`: get data about an ability.
- [x] `-p | --pokemon`: display Pokémon that learn this ability.
- [ ] `berry`: get data about a berry.
- [x] `berry`: get data about a berry.
- [x] `item`: get data about an item.
- [x] `move`: get data about a move.
- [ ] `-p | --pokemon`: display Pokémon that learn this move.
Expand Down
43 changes: 9 additions & 34 deletions card_data/pipelines/defs/transformation/transform_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,17 @@
from dagster_dbt import DbtCliResource, dbt_assets
from pathlib import Path

from ..load.load_data import (
load_series_data,
data_quality_check_on_series,
load_set_data,
load_card_data
)

DBT_PROJECT_PATH = Path(__file__).joinpath("..", "..", "..", "poke_cli_dbt").resolve()

@dg.asset(deps=[load_series_data, data_quality_check_on_series, load_set_data, load_card_data], kinds=["dbt"])
def dbt_transformation(context: dg.AssetExecutionContext):
"""Run dbt build after all extract and load operations complete"""
import subprocess
import os

# Set environment variables for dbt
env = os.environ.copy()
env["SUPABASE_PASSWORD"] = os.getenv("SUPABASE_PASSWORD", "")

# Run dbt build
result = subprocess.run(
["dbt", "build"],
cwd=str(DBT_PROJECT_PATH),
env=env,
capture_output=True,
text=True
)

if result.returncode != 0:
context.log.error(f"dbt build failed: {result.stderr}")
raise Exception(f"dbt build failed: {result.stderr}")

context.log.info(f"dbt build completed successfully: {result.stdout}")
return "dbt build completed"
@dbt_assets(manifest=DBT_PROJECT_PATH / "target" / "manifest.json")
def poke_cli_dbt_assets(context: dg.AssetExecutionContext, dbt: DbtCliResource):
"""
dbt assets that transform staging data into final models.
"""
yield from dbt.cli(["build"], context=context).stream()

# Create definitions for this transformation
dbt_resource = DbtCliResource(project_dir=DBT_PROJECT_PATH)
defs = dg.Definitions(
assets=[dbt_transformation]
assets=[poke_cli_dbt_assets],
resources={"dbt": dbt_resource}
)
24 changes: 24 additions & 0 deletions card_data/pipelines/poke_cli_dbt/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'poke_cli_dbt'
version: '1.7.0'

profile: 'poke_cli_dbt'

model-paths: ["models"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]

# directories removed by 'dbt clean'
clean-targets:
- "target"
- "dbt_packages"

models:
poke_cli_dbt:
# Transform staging data to public schema
+materialized: table

on-run-end:
- "{{ create_relationships() }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% macro create_relationships() %}
ALTER TABLE {{ ref('series') }} ADD CONSTRAINT pk_series PRIMARY KEY (id);
ALTER TABLE {{ ref('sets') }} ADD CONSTRAINT pk_sets PRIMARY KEY (set_id);
ALTER TABLE {{ ref('cards') }} ADD CONSTRAINT pk_cards PRIMARY KEY (id);
{% endmacro %}
4 changes: 4 additions & 0 deletions card_data/pipelines/poke_cli_dbt/macros/create_rls.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% macro enable_rls() %}
ALTER TABLE {{ this }} ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Enable read access for all users" ON {{ this }} TO PUBLIC USING (true);
{% endmacro %}
9 changes: 6 additions & 3 deletions card_data/pipelines/poke_cli_dbt/models/cards.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{ config(materialized='table') }}
{{ config(
materialized='table',
post_hook="{{ enable_rls() }}"
) }}

SELECT id, image, name, "localId", category
FROM {{ source('staging', 'cards') }}
SELECT id, image, name, "localId", category, hp
FROM {{ source('staging', 'cards') }}
7 changes: 7 additions & 0 deletions card_data/pipelines/poke_cli_dbt/models/series.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ config(
materialized='table',
post_hook="{{ enable_rls() }}"
) }}

SELECT *
FROM {{ source('staging', 'series') }}
7 changes: 7 additions & 0 deletions card_data/pipelines/poke_cli_dbt/models/sets.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ config(
materialized='table',
post_hook="{{ enable_rls() }}"
) }}

SELECT *
FROM {{ source('staging', 'sets') }}
6 changes: 3 additions & 3 deletions card_data/pipelines/soda/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ data_source supabase:
connection:
host: aws-0-us-east-2.pooler.supabase.com
port: '5432'
username: ${POSTGRES_USERNAME}
password: ${POSTGRES_PASSWORD}
username: ${SUPABASE_USER}
password: ${SUPABASE_PASSWORD}
database: postgres
schema: poke_data
schema: staging
18 changes: 18 additions & 0 deletions card_data/pipelines/utils/secret_retriever.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import botocore
import botocore.session
from aws_secretsmanager_caching import SecretCache, SecretCacheConfig

import json


def fetch_secret() -> str:
client = botocore.session.get_session().create_client("secretsmanager")
cache_config = SecretCacheConfig()
cache = SecretCache(config=cache_config, client=client)

secret = cache.get_secret_string("supabase-data")

# convert to dictionary
secret_dict = json.loads(secret)

return secret_dict["database_uri"]
1 change: 1 addition & 0 deletions card_data/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"aws-secretsmanager-caching>=1.1.3",
"beautifulsoup4>=4.13.5",
"dagster>=1.11.3",
"dagster-dbt>=0.27.3",
"dagster-dg-cli>=1.11.3",
Expand Down
26 changes: 26 additions & 0 deletions card_data/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"

"github.com/digitalghost-dev/poke-cli/cmd/ability"
"github.com/digitalghost-dev/poke-cli/cmd/berry"
"github.com/digitalghost-dev/poke-cli/cmd/item"
"github.com/digitalghost-dev/poke-cli/cmd/move"
"github.com/digitalghost-dev/poke-cli/cmd/natures"
Expand Down Expand Up @@ -69,6 +70,7 @@ func runCLI(args []string) int {
fmt.Sprintf("\n\t%-15s %s", "-v, --version", "Prints the current version"),
"\n\n", styling.StyleBold.Render("COMMANDS:"),
fmt.Sprintf("\n\t%-15s %s", "ability", "Get details about an ability"),
fmt.Sprintf("\n\t%-15s %s", "berry", "Get details about a berry"),
fmt.Sprintf("\n\t%-15s %s", "item", "Get details about an item"),
fmt.Sprintf("\n\t%-15s %s", "move", "Get details about a move"),
fmt.Sprintf("\n\t%-15s %s", "natures", "Get details about all natures"),
Expand Down Expand Up @@ -104,6 +106,7 @@ func runCLI(args []string) int {

commands := map[string]func() int{
"ability": utils.HandleCommandOutput(ability.AbilityCommand),
"berry": utils.HandleCommandOutput(berry.BerryCommand),
"item": utils.HandleCommandOutput(item.ItemCommand),
"move": utils.HandleCommandOutput(move.MoveCommand),
"natures": utils.HandleCommandOutput(natures.NaturesCommand),
Expand Down Expand Up @@ -140,6 +143,7 @@ func runCLI(args []string) int {
fmt.Sprintf("\n\t%-15s", fmt.Sprintf("'%s' is not a valid command.\n", cmdArg)),
styling.StyleBold.Render("\nCommands:"),
fmt.Sprintf("\n\t%-15s %s", "ability", "Get details about an ability"),
fmt.Sprintf("\n\t%-15s %s", "berry", "Get details about a berry"),
fmt.Sprintf("\n\t%-15s %s", "item", "Get details about an item"),
fmt.Sprintf("\n\t%-15s %s", "move", "Get details about a move"),
fmt.Sprintf("\n\t%-15s %s", "natures", "Get details about all natures"),
Expand Down
Loading
Loading