Skip to content
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

Attr vs item storage #50

Closed
nsheff opened this issue May 16, 2019 · 8 comments

Comments

@nsheff
Copy link
Contributor

commented May 16, 2019

updating the attmap doesn't update the to_yaml function:

In [45]: import attmap                                                                                                             

In [46]: mt = attmap.PathExAttMap()                                                                                                

In [47]: mt.attr = "value"                                                                                                         

In [48]: mt.attr                                                                                                                   
Out[48]: 'value'

In [49]: mt.to_yaml()                                                                                                              
Out[49]: '{}'

In [50]: mt.to_map()                                                                                                               
Out[50]: OrderedDict([('attr', 'value')])

In [51]: mt.to_dict()                                                                                                              
Out[51]: {'attr': 'value'}
In [55]: mt = attmap.PathExAttMap({"orig": "orig_value"})                                                                          

In [56]: mt.attr = "value"                                                                                                         

In [57]: mt.attr                                                                                                                   
Out[57]: 'value'

In [58]: mt.to_yaml()                                                                                                              
Out[58]: 'orig: orig_value\nattr: value'

In [59]: mt.orig = "new_value"                                                                                                     

In [60]: mt.to_yaml()                                                                                                              
Out[60]: 'orig: orig_value\nattr: value'
@nsheff

This comment has been minimized.

Copy link
Contributor Author

commented May 16, 2019

actually to_dict is also not updating it seems:

In [68]: mt.to_dict()                                                                                                              
Out[68]: {'attr': 'value', 'orig': 'orig_value'}

this is very strange I can't figure out what it's doing...

@nsheff nsheff added the bug label May 16, 2019

@nsheff

This comment has been minimized.

Copy link
Contributor Author

commented May 16, 2019

ok this looks like a pretty deep rooted problem that's not restricted to to_yaml. I'm going to hold off on doing more with updates for now because it looks like the update mechanisms are broken. I wonder if this is related to the recent looper bug?

Here I'm trying to assign a new value to an attribute, and it shows up when I then try to access the attribute, but not when I try to print it or save it to yaml:


In [71]: rgc.genomes                                                                                                               

In [73]: hasattr(rgc, "genomes")                                                                                                   
Out[73]: True

In [74]: not rgc.genomes                                                                                                           
Out[74]: True

In [75]: rgc.genomes = attmap.PathExAttMap()                                                                                       

In [76]: rgc.genomes                                                                                                               
Out[76]: PathExAttMap: {}

In [77]: rgc                                                                                                                       
Out[77]: 
RefGenomeConfiguration
genome_server: http://localhost
genome_folder: /ext/yeti/genomes
genomes: null

In [78]: print(rgc)                                                                                                                
RefGenomeConfiguration
genome_server: http://localhost
genome_folder: /ext/yeti/genomes
genomes: null

In [79]: rgc.genomes = attmap.PathExAttMap({"hg38": 1})                                                                            

In [80]: rgc                                                                                                                       
Out[80]: 
RefGenomeConfiguration
genome_server: http://localhost
genome_folder: /ext/yeti/genomes
genomes: null

In [81]: rgc.genomes                                                                                                               
Out[81]: 
PathExAttMap
hg38: 1

In [82]: rgc                                                                                                                       
Out[82]: 
RefGenomeConfiguration
genome_server: http://localhost
genome_folder: /ext/yeti/genomes
genomes: null

In [83]: print(rgc)                                                                                                                
RefGenomeConfiguration
genome_server: http://localhost
genome_folder: /ext/yeti/genomes
genomes: null

In [84]: attmap.__version__                                                                                                        
Out[84]: '0.11'
@nsheff

This comment has been minimized.

Copy link
Contributor Author

commented May 16, 2019

sorry, just realized I'm 2 hours behind on release! I"ll try it on 0.12.

@nsheff

This comment has been minimized.

Copy link
Contributor Author

commented May 16, 2019

Ok, I can confirm all these problems still on 0.12.

@vreuter

This comment has been minimized.

Copy link
Member

commented May 16, 2019

Will be fixed in 0.12.1 that's in progress. It's because item/attr storage differs

@vreuter vreuter added the known issue label May 16, 2019

@vreuter vreuter changed the title to_yaml only reflects original values Attr vs item storage May 16, 2019

@vreuter

This comment has been minimized.

Copy link
Member

commented May 16, 2019

The most basic type that should suffer this problem is OrdAttMap

@vreuter

This comment has been minimized.

Copy link
Member

commented May 17, 2019

This seems to be resolved in 0.12.1

@vreuter vreuter closed this May 17, 2019

@nsheff

This comment has been minimized.

Copy link
Contributor Author

commented May 17, 2019

🎆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.