Skip to content
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

Export to directory other than '.' fails #95

Open
agodbehere opened this issue Jun 22, 2018 · 1 comment
Open

Export to directory other than '.' fails #95

agodbehere opened this issue Jun 22, 2018 · 1 comment

Comments

@agodbehere
Copy link

Issue

Exporting to a directory such as corpora/ with bin/baleen export corpora results in an error like:
[Errno 2] No such file or directory: 'corpora/corpora/cooking/5b2d180b7af8b43e439b59b0.json'

This is a path expansion bug, as the second corpora/ in the path is not the desired behavior.

Resolution

The fix is straightforward. In version v0.3.3-85-g88d5d7c, line 211, remove self.root,.

So, for the block that reads:

for post, category in tqdm(self.posts(), total=Post.objects.count(), unit="docs"):
    path = os.path.join(
        self.root, catdir[category], "{}.{}".format(post.id, self.scheme)
    )

the revision should be:

for post, category in tqdm(self.posts(), total=Post.objects.count(), unit="docs"):
    path = os.path.join(
        catdir[category], "{}.{}".format(post.id, self.scheme)
    )

This change results in the desired behavior on export.

@bbengfort
Copy link
Member

Thanks @agodbehere for the bug report and the clear solution! You're right, there was a duplication of self.root in catdir[category]; I've implemented the change you suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants