-
Notifications
You must be signed in to change notification settings - Fork 81
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
Epiphyte synprop req #409
Epiphyte synprop req #409
Changes from all commits
056d426
3041d95
9579437
5f046c2
c546575
0f2034d
92a3dbb
3e652d4
74e944a
2158c11
9ad07a8
cd89c5d
86acf89
258cc62
6ef7ea4
dcc7557
9732028
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,7 @@ def __init__(self, load=True): | |
self.props = {} | ||
self.forms = set() | ||
|
||
self.reqprops = collections.defaultdict(list) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good call on keeping these in an optimized lookup |
||
self.defvals = collections.defaultdict(list) | ||
self.subprops = collections.defaultdict(list) | ||
self.propsbytype = collections.defaultdict(list) | ||
|
@@ -125,10 +126,11 @@ def __init__(self, load=True): | |
self.addTufoProp('syn:form', 'ptype', ptype='syn:type', req=1, doc='Synapse type for this form') | ||
|
||
self.addTufoForm('syn:prop', ptype='syn:prop') | ||
self.addTufoProp('syn:prop', 'doc', ptype='str', req=1, doc='Description of the property definition') | ||
# TODO - Re-enable syn:prop:doc req = 1 after cleaning up property docstrings. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd add another story to track adding docstrings for all props and enabling this. We should inform users before enabling this to avoid private models breaking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @therealsilence has a story for doing all these docs already. |
||
self.addTufoProp('syn:prop', 'doc', ptype='str', req=0, doc='Description of the property definition') | ||
self.addTufoProp('syn:prop', 'form', ptype='syn:prop', req=1, doc='Synapse form which contains this property') | ||
self.addTufoProp('syn:prop', 'ptype', ptype='syn:type', req=1, doc='Synapse type for this field') | ||
self.addTufoProp('syn:prop', 'req', ptype='bool', defval=0, doc='Set to 1 if this property is required') | ||
self.addTufoProp('syn:prop', 'req', ptype='bool', defval=0, doc='Set to 1 if this property is required to form the node.') | ||
self.addTufoProp('syn:prop', 'glob', ptype='bool', defval=0, doc='Set to 1 if this property defines a glob') | ||
self.addTufoProp('syn:prop', 'defval', doc='Set to the default value for this property') | ||
|
||
|
@@ -264,6 +266,7 @@ def addPropDef(self, prop, **info): | |
raise s_common.DupPropName(name=prop) | ||
|
||
info.setdefault('doc', None) | ||
info.setdefault('req', False) | ||
info.setdefault('uniq', False) | ||
info.setdefault('ptype', None) | ||
info.setdefault('title', None) | ||
|
@@ -279,6 +282,10 @@ def addPropDef(self, prop, **info): | |
if defval is not None: | ||
self.defvals[form].append((prop, defval)) | ||
|
||
req = info.get('req') | ||
if req: | ||
self.reqprops[form].append(prop) | ||
|
||
pdef = (prop, info) | ||
|
||
ptype = info.get('ptype') | ||
|
@@ -299,6 +306,18 @@ def getFormDefs(self, form): | |
''' | ||
return self.defvals.get(form, ()) | ||
|
||
def getFormReqs(self, form): | ||
''' | ||
Return a list of prop values which are required form a form. | ||
|
||
Args: | ||
form (str): Form to request values for. | ||
|
||
Returns: | ||
list: List of required properties needed for making the given form. | ||
''' | ||
return self.reqprops.get(form, ()) | ||
|
||
def _addSubRefs(self, pdef): | ||
name = pdef[0] | ||
for prop in s_tags.iterTagUp(pdef[0], div=':'): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,7 +121,7 @@ class NoInitCore(Exception): pass # API disabled because no cortex | |
class NoCurrSess(Exception): pass # API requires a current session | ||
|
||
class SidNotFound(Exception): pass | ||
class PropNotFound(Exception): pass | ||
class PropNotFound(SynErr): pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should create a story to make all of these Exceptions SynErrs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vertexmc we do have one in our backlog |
||
|
||
class HitMaxTime(Exception): pass | ||
class HitMaxRetry(Exception): pass | ||
|
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.
So if enforce mode is off, required props are not required. (thinking aloud)
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.
@vertexmc this is per @invisig0th