-
Notifications
You must be signed in to change notification settings - Fork 41
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
Implement project admin commands. Fixes #8 #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good. However, I'm not sure that the commands use the optimal output format. Especially the show-project
output looks messy.
How about using a multiple column format similar to the virsh
tool that is used for managing KVM virtual machines? See https://www.centos.org/docs/5/html/5.2/Virtualization/sect-Virtualization-Commands_for_Red_Hat_Virtualization-virsh_the_command_line_interface_tool_for_virtualization.html for some examples.
The show-project
command could use a key-value output format similar to the virsh dominfo
command.
Very true. I'll look into this. |
Now
What do you think? |
Much better now. In |
Ok, I'll remove 'em. |
How about this mocked up output style:
|
I also tweaked the test so that running them doesn't affect any other indices that may be in the database. |
Ok, looks nice. I'll update. |
|
Weird. The only way I managed to reproduce this error was to first create a project with insufficient arguments (e.g. provide only a name but not language or analyzer information) and then try to list the available projects. Creating projects with insufficient arguments is no longer possible but it seems that the code analyzers now deem the createProject function too complex. I'll refactor. |
That's probably the reason. I had created the project without specifying all the parameters. |
annif/annif.py
Outdated
# Create an index for the project | ||
index.create(index=proj_indexname) | ||
if not projectid or not language or not analyzer: | ||
print('Usage: annif create-project <projectId> --language <lang>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a space after <lang>
annif/annif.py
Outdated
projects = [x['_source'] for x in results['hits']['hits']] | ||
|
||
def parseRow(col1, col2, col3): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick on naming: I would call this function formatRow
, not parseRow
. What it does is the opposite of parsing...
annif/annif.py
Outdated
@@ -32,10 +33,15 @@ | |||
} | |||
|
|||
|
|||
def parseIndexname(projectid): | |||
def parse_indexname(projectid): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be format_indexname
or even better format_index_name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, fixing.
tests/test_annif.py
Outdated
assert not index.exists(annif.parse_indexname(FAILED_PROJECT)) | ||
|
||
|
||
def test_showproject(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to test_show_project
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes.
tests/test_annif.py
Outdated
|
||
|
||
def test_dropProject(): | ||
result = runner.invoke(annif.dropProject, [TEMP_PROJECT]) | ||
def test_dropproject(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, test_drop_project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the latest commit.
tests/test_annif.py
Outdated
@@ -25,31 +30,51 @@ def test_start(): | |||
|
|||
def test_init(): | |||
result = runner.invoke(annif.init) | |||
assert index.exists('annif') | |||
assert index.exists(annif.annif.config['INDEX_NAME']) | |||
assert result.exit_code == 0 | |||
|
|||
|
|||
def test_listprojects(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to test_list_projects
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the latest commit.
A basic implementation for project administration commands. The
annif init
command also now checks for orphaned indexes and removes them if necessary.