Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hotosm/osm-rawdata
Browse files Browse the repository at this point in the history
Sync with main.
  • Loading branch information
robsavoye committed Jan 28, 2024
2 parents c69d807 + 5a804a4 commit 7d2d5a2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 102 deletions.
1 change: 0 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ jobs:
uses: hotosm/gh-workflows/.github/workflows/[email protected]
needs: [build_doxygen]
with:
image: ghcr.io/${{ github.repository }}:ci
doxygen: true
13 changes: 5 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ repos:
- id: commitizen
stages: [commit-msg]

# Autoformat: Python code
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black

# Lint / autoformat: Python code
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: "v0.1.6"
hooks:
# Run the linter
- id: ruff
args: [--exit-non-zero-on-fix]
args: [--fix, --exit-non-zero-on-fix]
# Run the formatter
- id: ruff-format

# Autoformat: YAML, JSON, Markdown, etc.
- repo: https://github.com/pre-commit/mirrors-prettier
Expand All @@ -29,7 +26,7 @@ repos:

# Lint: Markdown
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.37.0
rev: v0.38.0
hooks:
- id: markdownlint
args: [--fix, --ignore, CHANGELOG.md]
83 changes: 0 additions & 83 deletions CODE_OF_CONDUCT.md

This file was deleted.

6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ FROM runtime as ci
ARG PYTHON_IMG_TAG
COPY --from=extract-deps \
/opt/python/requirements-ci.txt /opt/python/
RUN mv /root/.local/bin/* /usr/local/bin/ \
&& mv /root/.local/lib/python${PYTHON_IMG_TAG}/site-packages/* \
RUN cp -r /root/.local/bin/* /usr/local/bin/ \
&& cp -r /root/.local/lib/python${PYTHON_IMG_TAG}/site-packages/* \
/usr/local/lib/python${PYTHON_IMG_TAG}/site-packages/ \
&& set -ex \
&& apt-get update \
Expand All @@ -131,7 +131,7 @@ RUN mv /root/.local/bin/* /usr/local/bin/ \
&& pip install --upgrade --no-warn-script-location \
--no-cache-dir -r \
/opt/python/requirements-ci.txt \
&& rm -r /opt/python \
&& rm -r /opt/python && rm -r /root/.local \
# Pre-compile packages to .pyc (init speed gains)
&& python -c "import compileall; compileall.compile_path(maxlevels=10, quiet=1)"
# Override entrypoint, as not possible in Github action
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<a href="https://pypistats.org/packages/osm-rawdata" target="_blank">
<img src="https://img.shields.io/pypi/dm/osm-rawdata.svg" alt="Downloads">
</a>
<a href="https://github.com/hotosm/osm-rawdata/blob/main/LICENSE" target="_blank">
<a href="https://github.com/hotosm/osm-rawdata/blob/main/LICENSE.md" target="_blank">
<img src="https://img.shields.io/github/license/hotosm/osm-rawdata.svg" alt="License">
</a>
</p>
Expand Down
5 changes: 4 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ markdown_extensions:

plugins:
- search
- git-revision-date-localized
- exclude:
glob:
- plugins/*
Expand Down Expand Up @@ -74,5 +75,7 @@ nav:
- YAML: yaml.md
- Overture: overture.md
- API: api.md
- License: LICENSE
- License: LICENSE.md
- Changelog: CHANGELOG.md
- Code of Conduct: https://docs.hotosm.org/code-of-conduct
- Versioning: https://docs.hotosm.org/dev-guide/version-control/#creating-releases
18 changes: 13 additions & 5 deletions osm_rawdata/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ def __init__(
except Exception as e:
log.error(f"Couldn't connect to database: {e}")

def __del__(self):
"""
Close any open connections to Postgres.
"""
self.dbshell.close()

def createJson(
self,
config: QueryConfig,
Expand Down Expand Up @@ -259,10 +265,6 @@ def createSQL(
select += "ST_AsText(ST_Centroid(geom))"
select += ", osm_id, version, "
for entry in config.config["select"][table]:
if type(entry) == str:
import epdb

epdb.st()
for k1, v1 in entry.items():
select += f"tags->>'{k1}', "
select = select[:-2]
Expand All @@ -287,6 +289,12 @@ def createSQL(
jor = ""
for entry in join_or:
for k, v in entry.items():
if type(v[0]) == list:
# It's an array of values
value = str(v[0])
any = f"ANY(ARRAY{value})"
jor += f"tags->>'{k}'={any} OR "
continue
if k == "op":
continue
if len(v) == 1:
Expand Down Expand Up @@ -382,7 +390,7 @@ def queryLocal(
elif query.find(" relations ") > 0:
query = query.replace("relations", "relations_view")

log.debug(query)
# log.debug(query)
self.dbcursor.execute(query)
try:
result = self.dbcursor.fetchall()
Expand Down

0 comments on commit 7d2d5a2

Please sign in to comment.