Skip to content

Commit

Permalink
perf(removing-files-on-temp): temp file removal
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Jul 10, 2023
1 parent 02c90e8 commit 064542d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/monthly_global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
OSM_USERNAME: ${{ secrets.OSM_USERNAME }}
OSM_PASSWORD: ${{ secrets.OSM_PASSWORD }}
run: |
osmsg --url "https://planet.openstreetmap.org/replication/day" --format image csv --last_month --tags 'building' 'highway' 'waterway' 'amenity' --name stats/Global/Monthly/stats --read_from_metadata stats/Global/Monthly/stats_metadata.json --all_tags --charts --summary --meta
osmsg --url "https://planet.openstreetmap.org/replication/day" --format image csv --last_month --tags 'building' 'highway' 'waterway' 'amenity' --name stats/Global/Monthly/stats --read_from_metadata stats/Global/Monthly/stats_metadata.json --all_tags --charts --summary --meta --temp
- name: add stats to git

Expand Down Expand Up @@ -63,4 +63,3 @@ jobs:
run: |
commit_id=$(git rev-parse --short HEAD)
python tweet.py --git $commit_id --name stats/Global/Monthly/stats --tweet 'OSM Last Month' --mention '@openstreetmap'
5 changes: 2 additions & 3 deletions .github/workflows/monthly_nepal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ jobs:
OSM_USERNAME: ${{ secrets.OSM_USERNAME }}
OSM_PASSWORD: ${{ secrets.OSM_PASSWORD }}
run: |
osmsg --url "http://download.geofabrik.de/asia/nepal-updates" --username '${{ secrets.OSM_USERNAME }}' --password '${{ secrets.OSM_PASSWORD }}' --format image csv --last_month --tags 'building' 'highway' 'waterway' 'amenity' --name stats/Nepal/Monthly/stats --read_from_metadata stats/Nepal/Monthly/stats_metadata.json --all_tags --summary --charts --meta
osmsg --url "http://download.geofabrik.de/asia/nepal-updates" --username '${{ secrets.OSM_USERNAME }}' --password '${{ secrets.OSM_PASSWORD }}' --format image csv --last_month --tags 'building' 'highway' 'waterway' 'amenity' --name stats/Nepal/Monthly/stats --read_from_metadata stats/Nepal/Monthly/stats_metadata.json --all_tags --summary --charts --meta --temp
- name: add stats to git

run: |
git pull
git config --global user.email "[email protected]"
git config --global user.name "kshitijrajsharma"
base_dir=stats/Nepal/Monthly
mkdir -p $base_dir
Expand All @@ -63,4 +63,3 @@ jobs:
run: |
commit_id=$(git rev-parse --short HEAD)
python tweet.py --git $commit_id --name stats/Nepal/Monthly/stats --tweet 'Nepal Last Month'
9 changes: 9 additions & 0 deletions osmsg/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ def process_changefiles(url):
except Exception as ex:
print(f"File may be corrupt : Error at {url} : {ex}")

if remove_temp_files:
os.remove(file_path[:-3])


def process_changesets(url):
# print(f"Processing {url}")
Expand All @@ -441,6 +444,9 @@ def process_changesets(url):
except Exception as ex:
print(f"File may be corrupt : Error at {url} : {ex}")

if remove_temp_files:
os.remove(file_path[:-3])


def auth(username, password):
print("Authenticating...")
Expand Down Expand Up @@ -786,6 +792,7 @@ def main():
global collect_field_mappers_stats
global geom_filter_df
global geom_boundary
global remove_temp_files

all_tags = args.all_tags
additional_tags = args.tags
Expand All @@ -796,6 +803,8 @@ def main():
summary = args.summary
collect_field_mappers_stats = args.field_mappers
geom_boundary = args.boundary
remove_temp_files = args.temp

if args.boundary:
if not args.changeset and not args.hashtags:
args.changeset = True
Expand Down
2 changes: 1 addition & 1 deletion osmsg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ def process_boundary(input_data):
geom = polygons[0]
### return geom gdf here
gdf = gpd.GeoDataFrame(geometry=gpd.GeoSeries(geom))
print("Filtering data with: ",gdf)
print("Filtering data with: ", gdf)
return gdf


Expand Down
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "osmsg"
version = "0.1.31"
description = "OpenStreetMap Stats Generator : Commandline"
readme = "README.md"
homepage = "https://github.com/kshitijrajsharma/OSMSG"
authors = [{name = "Kshitij Raj Sharma", email = "[email protected]"}]
license = "MIT"

[tool.poetry.dependencies]
python = "^3.6"
osmium = "*"
pandas = "==1.5.2"
requests = "*"
shapely = "*"
geopandas = "==0.10.2"
tqdm = "*"
seaborn = "*"
matplotlib = "*"
humanize = "*"

[tool.poetry.scripts]
osmsg = "osmsg.app:main"

[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "v$version"
version_scheme = "semver"
version_provider = "pep621"
update_changelog_on_bump = true

0 comments on commit 064542d

Please sign in to comment.