-
Notifications
You must be signed in to change notification settings - Fork 27
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
extended FSWTabDict class #377
base: master
Are you sure you want to change the base?
Conversation
@JimHofman Looks like you still need to declare your newCmd as an extension in the config.yaml See: https://ait-core.readthedocs.io/en/master/extensions.html Config yaml would contain an entry that looks like:
Would presumably need something similar for the table extension. |
I'll check that out Nick. I was sure I had added those. Hmmm. Thanks Nick. |
Hey @JimHofman, replying here with regards to the issue(s) you're running into with the table extension support. Thanks for throwing this branch up so we have something to dig through. It looks like you got the "general extension" stuff added and working correctly. That's why you can see log message indicating that the extension class has been added. However, it's not getting fully pulled in for a few reasons (I think).
These functions are used by the custom YAML class handling stuff when processing the dictionary
So, if you import the table dictionary you'll see a message indicating that the extension was loaded but it's never going to actually load your class because the above functions (and others in the code) are calling explicit class names instead of the "extensions classes". These Looking through the table code really quickly (so you should sanity check that I'm not missing something) I think you need to make the following modifications: |
Table extensions now work. Created a newTable.py to override FSWTabDict. class NewFSWTabDict(table.FSWTabDict):
Used the following to instantiate and verify:
|
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.
Please see comments.
I think createFSWxxx
methods should be auto generated during the extension process. Otherwise it would throw error when no extension is defined in the config.
Also the branch has conflicts with current master.
ait/core/cmd.py
Outdated
def YAMLCtor_include(loader, node): | ||
# Get the path out of the yaml file | ||
name = os.path.join(os.path.dirname(loader.name), node.value) | ||
data = None | ||
with open(name,'r') as f: | ||
data = yaml.load(f) | ||
data = yaml.load(f, Loader=yaml.Loader) |
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 this necessary?
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.
I took out loader=yaml.loader.
We might want to get rid of data=None and use a try/except around the open block.
ait/core/dtype.py
Outdated
@@ -71,7 +71,7 @@ | |||
import sys | |||
import re | |||
|
|||
from ait.core import cmd, dmc, log, util | |||
from ait.core import cmd, dmc, log, util, table |
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.
table
is not reference in this module
@@ -427,7 +432,7 @@ def create(self, name, *args): | |||
tab = None | |||
defn = self.get(name, None) | |||
if defn: | |||
tab = FSWTab(defn, *args) | |||
tab = createFSWTab(defn, *args) |
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.
createFSWTab
method not defined
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.
Done
@@ -461,7 +466,7 @@ def dirty(self): | |||
def load(self): | |||
if self.fswtabdict is None: | |||
if self.dirty(): | |||
self.fswtabdict = FSWTabDict(self.filename) | |||
self.fswtabdict = createFSWTabDict(self.filename) |
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.
createFSWTabDict
not defined
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.
Done
|
||
|
||
def YAMLCtor_FSWTabDefn(loader, node): | ||
fields = loader.construct_mapping(node, deep=True) | ||
fields['fswheaderdefns'] = fields.pop('header', None) | ||
fields['coldefns'] = fields.pop('columns', None) | ||
return FSWTabDefn(**fields) | ||
return createFSWTabDefn(**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.
createFSWTabDict
not defined
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.
Done
config/config.yaml
Outdated
ait.core.table.FSWTabDict: ait.core.newTable.NewFSWTabDict |
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 are testing codes?
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.
Yes that is for testing. I took it out.
Correct, the createXxx() methods are implicitly added here: Line 148 in 5b9a247
|
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.
Please see comment. Thanks!
ait/core/cmd.py
Outdated
def YAMLCtor_include(loader, node): # noqa | ||
# Get the path out of the yaml file | ||
name = os.path.join(os.path.dirname(loader.name), node.value) | ||
data = None | ||
with open(name, "r") as f: | ||
data = yaml.load(f) | ||
return data |
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 overwrites previous definition of YAMLCtor_include
. Is this done on purpose?
ait/core/table.py
Outdated
@@ -434,7 +433,7 @@ def create(self, name, *args): | |||
tab = None | |||
defn = self.get(name, None) | |||
if defn: | |||
tab = createFSWTab(defn, *args) | |||
tab = FSWTab(defn, *args) |
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.
Sorry, my comment from last review was incorrect. The createFSWxxx
method gets created in run-time during the extension process (i.e. util.__init_extensions__
). So it is okay to call createFSWxxx
method here. Please revert back to before this commit.
ait/core/table.py
Outdated
@@ -468,7 +467,7 @@ def dirty(self): | |||
def load(self): | |||
if self.fswtabdict is None: | |||
if self.dirty(): | |||
self.fswtabdict = createFSWTabDict(self.filename) | |||
self.fswtabdict = FSWTabDict(self.filename) |
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.
Sorry, my comment from last review was incorrect. The createFSWxxx
method gets created in run-time during the extension process (i.e. util.__init_extensions__
). So it is okay to call createFSWxxx
method here. Please revert back to before this commit.
ait/core/table.py
Outdated
@@ -504,14 +503,14 @@ def getDefaultDict(): # noqa: N802 | |||
|
|||
def YAMLCtor_FSWColDefn(loader, node): # noqa: N802 | |||
fields = loader.construct_mapping(node, deep=True) | |||
return createFSWColDefn(**fields) | |||
return FSWColDefn(**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.
Sorry, my comment from last review was incorrect. The createFSWxxx
method gets created in run-time during the extension process (i.e. util.__init_extensions__
). So it is okay to call createFSWxxx
method here. Please revert back to before this commit.
ait/core/table.py
Outdated
return createFSWTabDefn(**fields) | ||
fields["fswheaderdefns"] = fields.pop("header", None) | ||
fields["coldefns"] = fields.pop("columns", None) | ||
return FSWTabDefn(**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.
Sorry, my comment from last review was incorrect. The createFSWxxx
method gets created in run-time during the extension process (i.e. util.__init_extensions__
). So it is okay to call createFSWxxx
method here. Please revert back to before this commit.
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.
Ok, I made the changes back and update utll.py
No description provided.