aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/Makefile1
-rw-r--r--python/conf/settings.ini2
-rw-r--r--python/refcat/tasks.py28
3 files changed, 31 insertions, 0 deletions
diff --git a/python/Makefile b/python/Makefile
index 647a3c3..1ea6c31 100644
--- a/python/Makefile
+++ b/python/Makefile
@@ -44,6 +44,7 @@ fmt:
clean:
rm -rf .pytest_cache/
rm -rf build/
+ rm -rf dist/
rm -rf $(PKGNAME).egg-info/
rm -rf $(ZIPAPP)
find . -name "__pycache__" -exec rm -rf "{}" +
diff --git a/python/conf/settings.ini b/python/conf/settings.ini
index e79153c..b6d42c9 100644
--- a/python/conf/settings.ini
+++ b/python/conf/settings.ini
@@ -39,3 +39,5 @@ RELEASE_EXPORT_EXPANDED_FILE = "/bigger/citations/release_export_expanded.json.z
# MAG directory.
MAG = "/magna/data/mag-2020-06-25"
+
+OL_DUMP = "/magna/data/open_library_2021-04-26.jsonl.zst"
diff --git a/python/refcat/tasks.py b/python/refcat/tasks.py
index bb2685d..182a51f 100644
--- a/python/refcat/tasks.py
+++ b/python/refcat/tasks.py
@@ -191,6 +191,10 @@ class WikipediaCitationsMinimalDataset(luigi.ExternalTask, Refcat):
def output(self):
return luigi.LocalTarget(path=os.path.join(settings.WIKIPEDIA_CITATIONS, "minimal_dataset.json"))
+class OpenLibraryDump(luigi.ExternalTask, Refcat):
+
+ def output(self):
+ return luigi.LocalTarget(path=settings.OL_DUMP, format=Zstd)
# ----8< Derivations
@@ -1449,3 +1453,27 @@ class WithISBN(Refcat):
def output(self):
return luigi.LocalTarget(path=self.path(ext="json.zst"), format=Zstd)
+
+
+class OpenLibraryWorks(Refcat):
+ """
+ Extract just the works.
+ """
+ def requires(self):
+ return OpenLibraryDump()
+
+ def run(self):
+ output = shellout("""
+ zstdcat -T0 {input} |
+ parallel -j {n} --block 10M --pipe "jq -rc 'select(.type == \\"work\\")'" |
+ zstd -T0 -c > {output}
+ """,
+ n=self.n,
+ tmpdir=self.tmpdir,
+ input=self.input().path)
+ luigi.LocalTarget(output).move(self.output().path)
+
+ def output(self):
+ return luigi.LocalTarget(path=self.path(ext="json.zst"), format=Zstd)
+
+