airbnb / knowledge-repo

A next-generation curated knowledge sharing platform for data scientists and other technical professions.
Apache License 2.0
5.48k stars 688 forks source link

Improve user-facing error messages in the post submission flow #272

Open shashj199 opened 7 years ago

shashj199 commented 7 years ago

Auto-reviewers: @NiharikaRay @matthewwardrop @earthmancash @danfrankj

Hey,

I'm not able to run Knowledge repo on a Mac system. I installed knowledge repo in a virtual environment with python 2.7. I ran the following command

knowledge_repo --repo 454_repo/ preview 454_repo/project/454_ipynb.kp/

I got the following error:

Traceback (most recent call last): File "/Users/shashank/Envs/knowledgerepo2/bin/knowledge_repo", line 278, in repo.set_active_draft(kp_path) # TODO: Deprecate File "/Users/shashank/Envs/knowledgerepo2/lib/python2.7/site-packages/knowledge_repo/repositories/gitrepository.py", line 158, in set_active_draft self.config.published_branch = branch.name AttributeError: 'NoneType' object has no attribute 'name'

Could you let me know the issue if it is already resolved? The repo was originally created in a Linux system.

Thanks a lot

matthewwardrop commented 7 years ago

Hi @shashj199 ,

We are using the knowledge repo on MacOS systems all the time, so this is odd indeed. Can you share the contents of the .knowledge_repo_config.py file in your git repository? Or are you using a DBKnowledgeRepository?

shashj199 commented 7 years ago
# Configuration for this knowledge data repository.

# A function called to see whether a specified path is permitted in the repository
# Only enforced when creating/modifying posts. It should return the path as a standard
# unix path (virtual folders separated by '/' and the final node should end in '.kp').
# It should raise an exception if the provided path is is not permitted in the knowledge
# repository.
def path_parse(path):
    return path

# A dictionary of aliases which point to knowledge posts. This allows you to alias posts
# which may be useful to forward old links to new locations, or to give certain posts
# precedence. It also allows the post path to violate the normal naming rules of posts.
# The only condition is that they cannot mask an existing post url, in which case the
# alias is silently ignored.
aliases = {}

# Postprocessors to apply when importing KnowledgePost objects into the repository.
# Note that KnowledgePost objects by default run 'extract_images' and 'format_checks'.
# Order is important.
postprocessors = []

# Usernames of users to keep informed of changes to the knowledge data repo
editors = []

# Function to check whether provided username is a valid username, and if not, mutate it
# such that it is. Should raise an exception if that is not possible, and otherwise
# return the parsed username.
def username_parse(username):
    return username

# Function to convert a username to a person's proper name
def username_to_name(username):
    return username

# Function to convert a username to a person's email
def username_to_email(username):
    return '{}@example.com'.format(username)

# Function to generate the web uri for a knowledge post at
# path `path`. If `None`, should return the web uri for
# the entire repository. Return `None` if a web uri does
# not exist.
def web_uri(path=None):
    return None

# WARNING: ADVANCED!
# Function that is called on a Flask web app instance before it is launched
# This is useful if you need to add a route for your local deployment, or other
# equally invasive action. Not recommended unless you know exactly what you are doing.
# It must return a KnowledgeFlask app instance.
def prepare_app(app):
    return app

The above are the contents. I first made a knowledge repo on a Ubuntu 17.04 system and cloned it to a Mac. I am able to create a knowledge repo from scratch on the same Mac.

Thanks

matthewwardrop commented 7 years ago

And does the repository have the knowledge_repo tools embedded into it? (Is there a .resources folder?)

shashj199 commented 7 years ago

No it doesn't have a .resources folder.

matthewwardrop commented 7 years ago

Ah... it was just a typo (with some poor error messages). You should have run: knowledge_repo --repo 454_repo/ preview 454_repo/project/454_ipynb.kp

Will keep this issue around to remind me to clean up the error messages.

shashj199 commented 7 years ago

I checked the command but it is still giving the same error. I checked another command to verify it is not some installation problem, so I deployed the web app and it worked. Only the preview is not working.

matthewwardrop commented 7 years ago

Sorry... I think I also carried on a typo from what you wrote:

It should be: knowledge_repo --repo 454_repo/ preview project/454_ipynb.kp

The path should be relative to the repo root.

shashj199 commented 7 years ago

Oh thanks a lot, it worked. I should have checked the documentation in more detail.

matthewwardrop commented 7 years ago

And our documentation should be better... thanks for your patience!