proknow.ScorecardTemplates¶
ScorecardTemplates¶
-
class
proknow.ScorecardTemplates.
ScorecardTemplates
(proknow, requestor)¶ This class should be used to interact with scorecard templates. It is instantiated for you as an attribute of the
proknow.ProKnow.ProKnow
class.-
create
(name, computed, custom)¶ Creates a new scorecard template.
Note
For information on how to construct computed metrics visit Computed Metrics.
For information on how to define scorecard objectives, see Scorecard Objectives.
- Parameters
name (str) – The scorecard name.
computed (list) – The computed metrics.
custom (list) – The custom metrics.
- Returns
A representation of the created scorecard template.
- Return type
- Raises
AssertionError – If the input parameters are invalid.
proknow.Exceptions.HttpError – If the HTTP request generated an error.
Example
This example creates a new scorecard template:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") pk.scorecard_templates.create("My Scorecard", [{ "type": "VOLUME", "roi_name": "BRAINSTEM", "arg_1": None, "arg_2": None }, { "type": "VOLUME_CC_DOSE_RANGE_ROI", "roi_name": "BRAINSTEM", "arg_1": 30, "arg_2": 60, "objectives": [{ "label": "IDEAL", "color": [18, 191, 0], "max": 0 }, { "label": "GOOD", "color": [136, 223, 127], "max": 3 }, { "label": "ACCEPTABLE", "color": [255, 216, 0], "max": 6 }, { "label": "MARGINAL", "color": [255, 102, 0], "max": 9 }, { "label": "UNACCEPTABLE", "color": [255, 0, 0] }] }], [{ "id": pk.custom_metrics.resolve_by_name("Genetic Type").id }])
-
delete
(scorecard_id)¶ Deletes a scorecard template by id.
- Parameters
scorecard_id (str) – The id of the scorecard template to delete.
- Raises
AssertionError – If the input parameters are invalid.
proknow.Exceptions.HttpError – If the HTTP request generated an error.
Example
If you know the scorecard template id, you can delete the scorecard template directly using this method:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") pk.scorecard_templates.delete('5c463a6c040040f1efda74db75c1b121')
-
find
(predicate=None, **props)¶ Finds the first scorecard that matches the input paramters.
Note
For more information on how to use this method, see Using Find Methods.
- Parameters
predicate (func) – A function that is passed a scorecard as input and which should return a bool indicating whether the scorecard is a match.
**props – A dictionary of keyword arguments that may include any scorecard attribute. These arguments are considered in turn to find matching scorecards.
- Returns
A summary representation of the matching scorecard.
- Return type
- Raises
proknow.Exceptions.HttpError – If the HTTP request generated an error.
-
get
(scorecard_id)¶ Gets a scorecard template by id.
- Parameters
scorecard_id (str) – The id of the scorecard template to get.
- Returns
A complete representation of the scorecard template
- Return type
- Raises
AssertionError – If the input parameters are invalid.
proknow.Exceptions.HttpError – If the HTTP request generated an error.
Example
If you know the scorecard template id, you can get the scorecard template directly using this method:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") pk.scorecard_templates.get('5c463a6c040068100c7f665acad17ac4')
-
query
()¶ Queries for scorecards templates.
- Returns
A list of
proknow.ScorecardTemplates.ScorecardTemplateSummary
objects, each representing a summarized scorecard template.- Return type
list
- Raises
AssertionError – If the input parameters are invalid.
proknow.Exceptions.HttpError – If the HTTP request generated an error.
Example
This example queries the scorecard templates and prints the name of each scorecard:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") for scorecard in pk.scorecard_templates.query(): print(scorecard.name)
-
resolve
(scorecard_template)¶ Resolves a scorecard template by id or name.
- Parameters
scorecard_template (str) – The scorecard template id or name.
- Returns
A summary representation of the resolved scorecard.
- Return type
- Raises
AssertionError – If the input parameters are invalid.
proknow.Exceptions.HttpError – If the HTTP request generated an error.
proknow.Exceptions.ScorecardTemplateLookupError – If the scorecard template with the given id or name could not be found.
-
resolve_by_id
(scorecard_template_id)¶ Resolves a scorecard template id to a scorecard template.
- Parameters
scorecard_template_id (str) – The scorecard template id.
- Returns
A summary representation of the resolved scorecard.
- Return type
- Raises
AssertionError – If the input parameters are invalid.
proknow.Exceptions.HttpError – If the HTTP request generated an error.
proknow.Exceptions.ScorecardTemplateLookupError – If the scorecard template with the given id could not be found.
-
resolve_by_name
(name)¶ Resolves a scorecard template name to a scorecard template in a case insensitive manner.
- Parameters
name (str) – The scorecard template name.
- Returns
A summary representation of the resolved scorecard.
- Return type
- Raises
AssertionError – If the input parameters are invalid.
proknow.Exceptions.HttpError – If the HTTP request generated an error.
proknow.Exceptions.ScorecardTemplateLookupError – If the scorecard template with the given name could not be found.
-
ScorecardTemplateSummary¶
-
class
proknow.ScorecardTemplates.
ScorecardTemplateSummary
(scorecard_templates, scorecard)¶ This class represents a summary view of a scorecard template. It’s instantiated by the
proknow.ScorecardTemplates.ScorecardTemplates.query()
method to represent each of the scorecards returned in a query result.-
id
¶ The id of the scorecard (readonly).
- Type
str
-
name
¶ The name of the scorecard (readonly).
- Type
str
-
data
¶ The summary representation of the scorecard as returned from the API (readonly).
- Type
dict
-
get
()¶ Gets the complete representation of the scorecard template.
- Returns
A complete representation of the scorecard template
- Return type
- Raises
proknow.Exceptions.HttpError – If the HTTP request generated an error.
Example
The following example shows how to turn a list of ScorecardTemplateSummary objects into a list of ScorecardTemplateItem objects:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") scorecards = [scorecard.get() for scorecard in pk.scorecard_templates.query()]
-
ScorecardTemplateItem¶
-
class
proknow.ScorecardTemplates.
ScorecardTemplateItem
(scorecard_templates, scorecard)¶ This class represents a scorecard template. It’s instantiated by the
proknow.ScorecardTemplates.ScorecardTemplates
class as a complete representation of the scorecard.-
id
¶ The id of the scorecard (readonly).
- Type
str
-
data
¶ The complete representation of the scorecard as returned from the API (readonly).
- Type
dict
-
name
¶ The name of the scorecard.
- Type
str
-
computed
¶ The computed metrics of the scorecard.
- Type
list
-
custom
¶ The custom metrics of the scorecard.
- Type
list
-
delete
()¶ Deletes the scorecard template.
- Raises
proknow.Exceptions.HttpError – If the HTTP request generated an error.
Example
The following example shows how to find a scorecard template by its name and delete it:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") scorecard = pk.scorecard_templates.find(name='My Scorecard').get() scorecard.delete()
-
save
()¶ Saves the changes made to a scorecard template.
Note
For information on how to construct computed metrics visit Computed Metrics.
For information on how to define scorecard objectives, see Scorecard Objectives.
- Raises
proknow.Exceptions.HttpError – If the HTTP request generated an error.
Example
The following example shows how to find a scorecard by its name, remove the associated custom metrics, and save it:
from proknow import ProKnow pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") scorecard = pk.scorecard_templates.find(name='My Scorecard').get() scorecard.custom = [] scorecard.save()
-