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

DM-14503: Implement YAML I/O for PropertySet/List. #94

Merged
merged 8 commits into from Jul 7, 2018
Merged

Conversation

ktlim
Copy link
Contributor

@ktlim ktlim commented May 30, 2018

No description provided.

@ktlim ktlim changed the title Implement YAML I/O for PropertySet/List. DM-14503: Implement YAML I/O for PropertySet/List. May 30, 2018
Copy link
Contributor

@r-owen r-owen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few questions and minor suggested changes.

"""Represent an lsst.daf.base.DateTime (as ISO8601-formatted string in UTC)
"""
return dumper.represent_scalar(u'lsst.daf.base.DateTime',
data.toString(lsst.daf.base.DateTime.UTC))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UTC time handling is broken, because the representation doesn't handle the string value when a leap second is added. I'm hoping we can ditch UTC support from this class. Please use TAI instead and/or rely on astropy to provide the string representation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? I thought it handled it with T23:59:60 (and that there was a test for this). I'll check later. The problem with TAI is that it is not absolutely clear that it is in use (the only indicator is the lack of "Z"), and I was expecting the YAML to be human-readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were right that lsst.daf.base.DateTime doesn't handle leap seconds in UTC (because it defers to gmtime). This is fixable with a few lines of code for past and near-future times (since we know the leap second table). I'm not sure if it's worth doing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should ditch UTC support from DateTime, but I suppose that's an RFC or RFD. In any case...please use astropy here if you want to save using UTC. But I'm keen on TAI; I think it's a much saner time standard and as long as we document what we're doing it'll be plenty human readable.

for name in data.getOrderedNames():
pairList.append([name, data.get(name), data.getComment(name)])
return dumper.represent_sequence(u'lsst.daf.base.PropertyList', pairList,
flow_style=None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You later modify this by adding type info. Could those commits be combined?

(Also...pairList for a list of 3-element tuples? That is a very misleading name. But with any luck you won't be keeping this commit)


from . import (LogicalLocation, Persistence, Policy, StorageList,
StorageInterface, Storage, ButlerLocation,
NoRepositroyAtRoot, RepositoryCfg, doImport)
from lsst.log import Log
import lsst.pex.policy as pexPolicy
from .safeFileIo import SafeFilename, safeMakeDir
from . import baseYaml # noqa F401
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please explain in the code comment why you are importing this

Parameters
----------
butlerLocation : ButlerLocation
The location & formatting for the object to be written.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the same question again (depending if "persistence format" and "format" mean the same thing): is the format specified by butlerLocation? If so, please say more in the doc string. If not, please remove "& formatting"

@@ -671,6 +673,25 @@ def writeParquetStorage(butlerLocation, obj):
obj.write(filename)


def writeYamlStorage(butlerLocation, obj):
"""Writes an object to a location and persistence format specified by
ButlerLocation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what way is the persistence format specified by butlerLocation? Isn't it always yaml?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just copying the comments from other similar methods. I can try to go through and fix them all up instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please

@@ -863,7 +884,13 @@ def readYamlStorage(butlerLocation):
for locationString in butlerLocation.getLocations():
logLoc = LogicalLocation(butlerLocation.getStorage().locationWithRoot(locationString),
butlerLocation.getAdditionalData())
finalItem = Policy(filePath=logLoc.locString())
if not os.path.exists(logLoc.locString()):
raise RuntimeError("No such YAML file: " + logLoc.locString())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused...why are you reading yaml data from a pickle (at least I assume it's a pickle based on the method name)? Have you changed the pickle format for PropertySet and PropertyList?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed the blue bar saying that the function had changed, I think. I did add pickle-ability for PropertySet over in daf_base so that I could use the getstate() function in the YAML representer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was not clear. Why is there an error message "No such YAML file" in a function named readPickleStorage? What does YAML have to do with pickle storage?

I don't understand your statement about a blue bar. I see is that readPickleStorage has changed dramatically and the changes seem to have nothing to do with pickle format. For instance below you now check for butlerLocation.pythonType == 'lsst.daf.persistence.RepositoryCfg' which doesn't seem like a pickle, and if that test fails, then read as a yaml file. I'm really confused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readPickleStorage (starting at line 695) has not changed at all. All these changes are in readYamlStorage (starting at line 870).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants