-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Features/#59 move resource management to importlib resources #119
base: dev
Are you sure you want to change the base?
Changes from 1 commit
6dc6872
cc48272
94aa973
213ba84
5b67185
c818704
3e98797
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,19 @@ | |
import egon.data.config | ||
import egon.data.subprocess as subprocess | ||
|
||
import egon.data.importing.openstreetmap as import_openstreetmap | ||
from importlib_resources import files | ||
|
||
|
||
def download_pbf_file(): | ||
"""Download OpenStreetMap `.pbf` file.""" | ||
data_config = egon.data.config.datasets() | ||
osm_config = data_config["openstreetmap"]["original_data"] | ||
|
||
target_file = os.path.join( | ||
os.path.dirname(__file__), osm_config["target"]["path"] | ||
#os.path.dirname(__file__), | ||
files(import_openstreetmap), | ||
osm_config["target"]["path"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no reason to split up the original line. Our automatic code formatting tool will join them again anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. |
||
) | ||
|
||
if not os.path.isfile(target_file): | ||
|
@@ -50,7 +55,9 @@ def to_postgres(num_processes=4, cache_size=4096): | |
data_config = egon.data.config.datasets() | ||
osm_config = data_config["openstreetmap"]["original_data"] | ||
input_file = os.path.join( | ||
os.path.dirname(__file__), osm_config["target"]["path"] | ||
#os.path.dirname(__file__), | ||
files(import_openstreetmap), | ||
osm_config["target"]["path"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will also be joined when formatting code. |
||
) | ||
|
||
# Prepare osm2pgsql command | ||
|
@@ -74,7 +81,8 @@ def to_postgres(num_processes=4, cache_size=4096): | |
" ".join(cmd), | ||
shell=True, | ||
env={"PGPASSWORD": docker_db_config["POSTGRES_PASSWORD"]}, | ||
cwd=os.path.dirname(__file__), | ||
#cwd=os.path.dirname(__file__), | ||
cwd=files(import_openstreetmap), | ||
) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line exceeds the 79 character limit. Also
os.path.dirname
just removes the'__init__.py'
component, sofiles(egon.data.airflow)
should suffice.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the
files(egon.data.airflow)
yieldsTypeError: str expected, not PosixPath
. So, I changed it tostr(files(egon.data.airflow))
. I hope addingstr()
is ok.