-
Notifications
You must be signed in to change notification settings - Fork 0
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
Story/VOGRE-32 #33
Story/VOGRE-32 #33
Conversation
Can one of the admins verify this patch? |
concepts/lifecycle.py
Outdated
response = requests.post(url=url, data=json.dumps(concept_data), auth=auth) | ||
|
||
if response.status_code != requests.codes.ok: | ||
raise RuntimeError(response.status_code, response.text) |
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.
this should happen in a conceptpower class not directly here.
concepts/lifecycle.py
Outdated
@@ -230,10 +172,16 @@ def merge_with(self, uri): | |||
children_queryset.update(merged_with=target) | |||
|
|||
def add(self): | |||
|
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.
remove empty line
concepts/lifecycle.py
Outdated
if 'conceptEntries' in data: | ||
for concept_entry in data['conceptEntries']: | ||
concept = self.parse_concept(concept_entry) | ||
concepts.append(concept) |
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.
same as above, should not happen in this class
concepts/lifecycle.py
Outdated
if 'conceptEntries' in data: | ||
for concept_entry in data['conceptEntries']: | ||
concept = self.parse_concept(concept_entry) | ||
concepts.append(concept) |
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.
same
concepts/lifecycle.py
Outdated
data = response.json() | ||
concept_entry = data.get('conceptEntries', [{}])[0] | ||
else: | ||
raise ValueError(f"Error fetching concept data: {response.status_code}") |
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.
same, there should be a conceptpower class that does all the communication with conceptpower (isn't there one already?)
concepts/conceptpower.py
Outdated
# Give first priority to the class definition, if endpoint or namespace are defined (and not None). | ||
if self.endpoint is None: | ||
self.endpoint = kwargs.get( | ||
"endpoint", "http://chps.asu.edu/conceptpower/rest/") |
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.
these should not be hard-coded; if a default is needed it should come from environment variables/settings.
concepts/conceptpower.py
Outdated
|
||
if self.namespace is None: | ||
self.namespace = kwargs.get( | ||
"namespace", "{http://www.digitalhps.org/}") |
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.
same here
concepts/conceptpower.py
Outdated
|
||
response = requests.get(url, headers=headers, params=params) | ||
concepts = [] | ||
if response.status_code == 200: |
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.
if not, we definitely want to log what else is returned and an error message if there is one.
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.
also, you want to use a constant (requests
probably has one) and not a magic number (even though it's an obvious one if you have done web application development before).
concepts/conceptpower.py
Outdated
url = "{0}Concept?id={1}".format(self.endpoint, uri) | ||
response = requests.get(url, headers=headers) | ||
data = {} | ||
if response.status_code == 200: |
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.
same here
|
||
def parse_concept(self,concept_entry): | ||
""" | ||
Parse a concept and return a dictionary with the required fields. |
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.
needs parameter description (what does this method accept to get in concept_entry
? maybe even put in example json (think about what would someone need to know to use this method if they don't see the code)).
|
||
|
||
class Conceptpower: | ||
# Default behavior is to leave these to the constructor. |
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.
what does this mean?
namespace = None | ||
|
||
def __init__(self, **kwargs): | ||
# Give first priority to the class definition, if endpoint or namespace are defined (and not None). |
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.
what does that mean?
CONCEPTPOWER_ENDPOINT = os.environ.get('CONCEPTPOWER_ENDPOINT') | ||
CONCEPTPOWER_NAMESPACE = os.environ.get('CONCEPTPOWER_NAMESPACE') | ||
CONCEPTPOWER_ENDPOINT = os.environ.get('CONCEPTPOWER_ENDPOINT', 'http://chps.asu.edu/conceptpower/rest/') | ||
CONCEPTPOWER_NAMESPACE = os.environ.get('CONCEPTPOWER_NAMESPACE', '{http://www.digitalhps.org/}') |
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.
why is the namespace in curly brackets?
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.
this one is fine, it's just a static github page
@@ -198,8 +198,8 @@ | |||
|
|||
CONCEPTPOWER_USERID = os.environ.get('CONCEPTPOWER_USERID') | |||
CONCEPTPOWER_PASSWORD = os.environ.get('CONCEPTPOWER_PASSWORD') | |||
CONCEPTPOWER_ENDPOINT = os.environ.get('CONCEPTPOWER_ENDPOINT') | |||
CONCEPTPOWER_NAMESPACE = os.environ.get('CONCEPTPOWER_NAMESPACE') | |||
CONCEPTPOWER_ENDPOINT = os.environ.get('CONCEPTPOWER_ENDPOINT', 'http://chps.asu.edu/conceptpower/rest/') |
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.
and let's not put that url here. even though it is in the github commit history now, we want to keep bot traffic to our servers as low as possible
Guidelines for Pull Requests
If you haven't yet read our code review guidelines, please do so, You can find them here.
Please confirm the following by adding an x for each item (turn
[ ]
into[x]
).Please provide a brief description of your ticket
Workflow
User goes to concept list page
User selects a concept that has not be resolved
If there is a viaf url, Vogon will search Conceptpower for that viaf url and show the result. If there is exactly one result, user should be able to say “approve”, if there are more, user should select one
User should also have the chance to do a conceptpower search for a search term and select one of the results.
If there is no viaf url, user should get a search field to search conceptpower and then be able to select one of the results or do a new search
For all of these options, there should also be a button to create a new concept in conceptpower.
Once a concept has been selected and approved, Vogon concept is RESOLVED
We will likely only have “Pending” and “resolved” as concept states.
... Put ticket description here and add link to ticket ...
https://diging.atlassian.net/browse/VOGRE-32
Are there any other pull requests that this one depends on?
Anything else the reviewer needs to know?
Below bug is fixed along with this PR: