Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

loc.py 1.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  1. import logging
  2. from invoke import task
  3. import support as s
  4. _log = logging.getLogger(__name__)
  5. @task(s.init)
  6. def init(c, force=False):
  7. if s.start('loc-mds-init', force=force, fail=False):
  8. _log.info('initializing LOC schema')
  9. s.psql(c, 'loc-mds-schema.sql')
  10. s.finish('loc-mds-init')
  11. else:
  12. _log.info('LOC schema initialized')
  13. @task(s.build, s.init, init)
  14. def import_books(c, force=False):
  15. "Import the LOC MDS data"
  16. s.start('loc-mds-books', force=force)
  17. loc = s.data_dir / 'LOC'
  18. files = list(loc.glob('BooksAll.2014.part*.xml.gz'))
  19. _log.info('importing LOC data from %d files', len(files))
  20. s.pipeline([
  21. [s.bin_dir / 'parse-marc', '--db-schema', 'locmds', '-t', 'book_marc_field', '--truncate'] + files
  22. ])
  23. s.finish('loc-mds-books')
  24. @task(s.init)
  25. def index_books(c, force=False):
  26. "Index LOC MDS books data"
  27. s.check_prereq('loc-mds-books')
  28. s.start('loc-mds-book-index', force=force)
  29. _log.info('building LOC indexes')
  30. s.psql(c, 'loc-mds-index-books.sql')
  31. s.finish('loc-mds-book-index')
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...