{"id":20486202,"url":"https://github.com/undp-data/geo-cb-surge","last_synced_at":"2025-03-05T16:31:11.885Z","repository":{"id":261675301,"uuid":"883827264","full_name":"UNDP-Data/geo-cb-surge","owner":"UNDP-Data","description":"A repo to hold python tools that facilitate the assessment of natural hazards over various domains like population, landuse, infrastructure, etc  ","archived":false,"fork":false,"pushed_at":"2025-02-28T14:37:31.000Z","size":9734,"stargazers_count":0,"open_issues_count":39,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-28T18:01:48.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rapida.undpgeohub.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UNDP-Data.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-05T16:34:41.000Z","updated_at":"2025-02-26T23:44:22.000Z","dependencies_parsed_at":"2024-12-09T14:22:44.723Z","dependency_job_id":"92e3f026-2660-4c4f-ab16-662561378838","html_url":"https://github.com/UNDP-Data/geo-cb-surge","commit_stats":null,"previous_names":["undp-data/geo-cb-surge"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UNDP-Data%2Fgeo-cb-surge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UNDP-Data%2Fgeo-cb-surge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UNDP-Data%2Fgeo-cb-surge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UNDP-Data%2Fgeo-cb-surge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UNDP-Data","download_url":"https://codeload.github.com/UNDP-Data/geo-cb-surge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242061168,"owners_count":20065675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T16:35:42.822Z","updated_at":"2025-03-05T16:31:11.871Z","avatar_url":"https://github.com/UNDP-Data.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# geo-cb-surge\nA repo to hold python tools that facilitate the assessment of natural hazards over various domains like population, landuse, infrastructure, etc  \n\n## Installation\n\nInstall the project with dependencies to virtual environment as below.\n\n```shell\npipenv run pip install -e .\n```\n\nIf you want to install optional dependencies for testing and jupyter, execute the following command.\n\n```shell\npipenv run pip install .[dev,jupyter]\n```\n\nTo uninstall the project from Python environment, execute the following command.\n\n```shell\npipenv run pip uninstall geo-cb-surge\n```\n\n## Usage\n\nThen, run the below command to show help menu.\n\n```shell\npipenv run rapida --help\n```\n\n## Setup\n\nTo access blob storage in Azure, each user must have a role of `Storage Blob Data Contributor`.\n\n- inside Docker container\n\nSince it has an issue of opening browser by azure.identity package inside docker container, use `az login` to authenticate prior to use API.\n\n```shell\naz login # authenticate with az login\npipenv run rapida init\n```\n\n- without Docker\n\n`init` command will open browser to authenticate to Azure\n\n```shell\npipenv run rapida init\n```\n\n## Admin\n\n`admin` command provides functionality to retrieve admin data for passed bounding bbox from either OpenStreetMap or OCHA.\n\n- OSM\n\n```shell\npipenv run rapida admin osm --help\n```\n\n- ocha\n\n```shell\npipenv run rapida admin ocha --help\n```\n\n## Run test\n\nEach `cbsurge`'s modules has its own test suite which can be ran independently\n\n```shell\nmake test\n```\n\nbefore running the above command, please use `devcontainer` or `make shell` to enter to docker container first.\n\n## Using docker\n\n### build docker-image\n\n```shell\nmake build\n```\n\nIf you would like to build image for production, execute the below command\n\n```shell\nPRODUCTION=true make build\n```\n\n- launch docker container\n\n```shell\nmake up\n```\n\nYou can access to JupyterHub through `http:localhost:8100` in your browser. \n\n- set users\n\nAuthenticate users can be set through `JUPYTER_USERS` variable at `.env` file.\n\n```\ncp .env.example .env\nvi .env\n```\n\nJUPYTER_USERS can have multiple users (username:password) for authentication\n\n```shell\nJUPYTER_USERS=docker:docker user:user\n```\n\nfolder structure in the container will be as follows:\n\n- /data - it will be mounted to fileshare. All files under this folder will be kept\n  - /data/{username} - users can explore all users file, a user has no permission to edit other users' folder.\n- /home/{username} - user home folder. This data will be lost when the server is restarted.\n\n### destroy docker container\n\n```shell\nmake down\n```\n\n### enter to Docker container\n\n```shell\nmake shell\npipenv run rapida --help # run CLI in shell on docker container\n```\n\n## Authenticate on local machine\n\nYou can login to UNDP account in local machine, then mount auth token information to the Docker. Thus, session class will use your local authentication info for the tool.\n\nFirstly, copy `env.example` to create `.env` locally.\n\nSet the following environmental variables.\n\n```shell\nTENANT_ID=\nCLIENT_ID=\n```\n\n`CLIENT_ID` (Use it from Microsoft Azure CLI) can be found [here](https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications).\n`TENANT_ID` is for UNDP. Please ask administrator for it.\n\ncreate new virtual environment in local machine (eg, pipenv), install the following dependencies.\n\n```shell\npip install msal azure-core playwright azure-storage-blob click\n```\n\nExecute below py file independently to authenticate in local machine.\n\n```shell\npython cbsurge/az/auth.py\n```\n\n`python cbsurge/az/auth.py --help` to show usage.\n\nUse `-c {cache_dir}` to change folder path to store `token_cache.json`.\n\nThe script will create token_cache.json at `~/cbsurge/token_cache.json`.\n\nOpen `docker-compose.yaml`. Uncomment the following code to mount json file from your local to the container.\n\nYou may need to adjust file path according to your environment settings.\n\n```yaml\nvolume:\n  - ~/.cbsurge/token_cache.json:/root/.cbsurge/token_cache.json\n```\n\nUsing the below command to setup rapida tool. If it shows `authentication successful` in the log, it uses credential from your local machine directly.\n\n```shell\nrapida init\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fundp-data%2Fgeo-cb-surge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fundp-data%2Fgeo-cb-surge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fundp-data%2Fgeo-cb-surge/lists"}