Skip to content

Commit 62bb7f7

Browse files
Automatically convert cache_dir string to path in script (#24)
* fix: convert cache_dir string into path automatically * chores: update script and configuration file to demonstrate case using downloaders
1 parent dcec460 commit 62bb7f7

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

04_workdir.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
logging:
55
handlers:
66
file:
7-
filename: logs/my_saezapp_logger.log
8-
7+
filename: logs/app_go_logger.log
98
loggers:
109
default:
1110
level: DEBUG
@@ -22,10 +21,6 @@ logging:
2221
handlers: [file, console]
2322
propagate: false
2423

25-
root:
26-
level: WARNING
27-
handlers: [file, console]
28-
2924
# -------------------------------------
3025
# ---- Integrations -----
3126
# -------------------------------------

ontograph/downloader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def __init__(
281281
'Install it to use DownloadManagerAdapter.'
282282
) from exc
283283

284-
self._cache_dir = cache_dir
284+
self._cache_dir = Path(cache_dir)
285285
self._cache_dir.mkdir(parents=True, exist_ok=True)
286286
self._manager = dm.DownloadManager(
287287
path=str(self._cache_dir),

sandbox/use_case_downloaders.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import pkg_infra
22

33
from ontograph.client import ClientCatalog, ClientOntology
4-
from ontograph.downloader import PoochDownloaderAdapter
5-
from ontograph.config.settings import DEFAULT_CACHE_DIR
4+
from ontograph.downloader import (
5+
PoochDownloaderAdapter,
6+
DownloadManagerAdapter)
7+
68

79
def main():
810
workspace = './'
11+
cache_dir = './data/out'
912

1013
# Create a session for the app
1114
session = pkg_infra.get_session(workspace=workspace, include_location=True)
@@ -21,17 +24,18 @@ def main():
2124
logger.critical('This is a CRITICAL message')
2225

2326
# Call a given downloader from OntoGraph
24-
downloader = PoochDownloaderAdapter(cache_dir=DEFAULT_CACHE_DIR)
27+
#downloader = PoochDownloaderAdapter(cache_dir=cache_dir)
28+
downloader = DownloadManagerAdapter(cache_dir=cache_dir)
2529

2630
# Download a catalog
27-
catalog = ClientCatalog(cache_dir='./data/out', downloader=downloader)
31+
catalog = ClientCatalog(cache_dir=cache_dir, downloader=downloader)
2832
catalog.load_catalog()
2933

3034
# print the schema tree
3135
#catalog.print_catalog_schema_tree()
3236

3337
# Download a given ontology
34-
client = ClientOntology(cache_dir='./data/out', downloader=downloader)
38+
client = ClientOntology(cache_dir=cache_dir, downloader=downloader)
3539
client.load(source='go') # catalog download
3640

3741
if __name__ == '__main__':

0 commit comments

Comments
 (0)