Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/run-python-script-datasetsinfo.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This workflow will install Python dependencies and run the script

name: run_datasetsinfo
name: Run datasets info

on:
workflow_dispatch: # add run button in github
Expand All @@ -26,17 +26,17 @@ jobs:
HDX_KEY: ${{ secrets.HDX_BOT_SCRAPERS_API_TOKEN }}
PREPREFIX: ${{ vars.HDX_USER_AGENT_PREPREFIX }}
USER_AGENT: ${{ vars.USER_AGENT }}
MIXPANEL_API_SECRET: ${{ secrets.MIXPANEL_API_SECRET }}
MIXPANEL_SERVICE_ACCOUNT_USERNAME: ${{ secrets.MIXPANEL_SERVICE_ACCOUNT_USERNAME }}
MIXPANEL_SERVICE_ACCOUNT_SECRET: ${{ secrets.MIXPANEL_SERVICE_ACCOUNT_SECRET }}
MIXPANEL_PROJECT_ID: ${{ secrets.MIXPANEL_PROJECT_ID }}
MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }}

# 'uv run' executes the command inside the environment created by 'uv sync'
run: |
uv run --frozen python -m hdx.analysis_scripts.datasets --output_dir=datasets_info

- name: Deploy 🚀
if: always()
uses: JamesIves/github-pages-deploy-action@v4
uses: JamesIves/github-pages-deploy-action@fa24774553152dd7873cd16ebd8d959b010c5445 # v4.9.0
with:
branch: gh-pages
folder: datasets_info
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/run-python-script-orgstats.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This workflow will install Python dependencies and run the script

name: run_orgstats
name: Run org stats

on:
workflow_dispatch: # add run button in github
Expand All @@ -26,17 +26,17 @@ jobs:
HDX_KEY: ${{ secrets.HDX_BOT_SCRAPERS_API_TOKEN }}
PREPREFIX: ${{ vars.HDX_USER_AGENT_PREPREFIX }}
USER_AGENT: ${{ vars.USER_AGENT }}
MIXPANEL_API_SECRET: ${{ secrets.MIXPANEL_API_SECRET }}
MIXPANEL_SERVICE_ACCOUNT_USERNAME: ${{ secrets.MIXPANEL_SERVICE_ACCOUNT_USERNAME }}
MIXPANEL_SERVICE_ACCOUNT_SECRET: ${{ secrets.MIXPANEL_SERVICE_ACCOUNT_SECRET }}
MIXPANEL_PROJECT_ID: ${{ secrets.MIXPANEL_PROJECT_ID }}
MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }}

# 'uv run' executes the command inside the environment created by 'uv sync'
run: |
uv run --frozen python -m hdx.analysis_scripts.orgs --output_dir=org_stats

- name: Deploy 🚀
if: always()
uses: JamesIves/github-pages-deploy-action@v4
uses: JamesIves/github-pages-deploy-action@fa24774553152dd7873cd16ebd8d959b010c5445 # v4.9.0
with:
branch: gh-pages
folder: org_stats
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 UN-OCHA Humanitarian Data Exchange Project
Copyright (c) 2026 UN-OCHA Humanitarian Data Exchange Project

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,22 @@ hdx-analysis-scripts:
user_agent: AnalysisScripts
```

These scripts require Mixpanel account credentials to operate, for local development the following environment variables need to be set:
These scripts require a Mixpanel service account to operate. For local development, either set
the following environment variables:

```
MIXPANEL_API_SECRET
MIXPANEL_SERVICE_ACCOUNT_USERNAME
MIXPANEL_SERVICE_ACCOUNT_SECRET
MIXPANEL_PROJECT_ID
MIXPANEL_TOKEN
```

Mixpanel accounts for users authenticate by sending a login email to registered users on login request.
or create `~/.mixpanel.yaml`:

```yaml
service_account_username: [USERNAME]
service_account_secret: [SECRET]
project_id: [PROJECT_ID]
```

### Pre-commit

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ keywords = ["HDX", "analysis"]
dynamic = ["version"]
requires-python = ">=3.13"
dependencies = [
"hdx-python-api>= 6.6.7",
"hdx-python-country>= 4.1.1",
"hdx-python-utilities>= 4.0.8",
"hdx-python-api>= 6.8.0",
"hdx-python-country>= 4.3.1",
"hdx-python-utilities>= 4.2.8",
"mixpanel-utils",
]
readme = "README.md"
Expand Down
12 changes: 6 additions & 6 deletions src/hdx/analysis_scripts/common/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ def get_mixpanel_downloads(self, months_ago):
logger.info("Getting downloads from MixPanel")
try:
mixpanel_config = load_yaml(self.mixpanel_config_yaml)
api_secret = mixpanel_config["api_secret"]
username = mixpanel_config["service_account_username"]
secret = mixpanel_config["service_account_secret"]
project_id = mixpanel_config["project_id"]
token = mixpanel_config["token"]
except FileNotFoundError:
api_secret = getenv("MIXPANEL_API_SECRET")
username = getenv("MIXPANEL_SERVICE_ACCOUNT_USERNAME")
secret = getenv("MIXPANEL_SERVICE_ACCOUNT_SECRET")
project_id = getenv("MIXPANEL_PROJECT_ID")
token = getenv("MIXPANEL_TOKEN")
mputils = MixpanelUtils(
api_secret=api_secret,
service_account_username=username,
service_account_password=secret,
project_id=project_id,
token=token,
)
start_date_str = start_date.strftime("%Y-%m-%d")
end_date_str = end_date.strftime("%Y-%m-%d")
Expand Down
Loading