Skip to content

[query][qob][hailtop/fs] Expose modification and creation time. - #12571

Merged
danking merged 7 commits into
hail-is:mainfrom
danking:fix-12540
Feb 4, 2023
Merged

[query][qob][hailtop/fs] Expose modification and creation time.#12571
danking merged 7 commits into
hail-is:mainfrom
danking:fix-12540

Conversation

@danking

@danking danking commented Dec 27, 2022

Copy link
Copy Markdown
Contributor

Fixes #12540.

CHANGELOG: When using Query-on-Batch, hl.hadoop* methods now properly support creation and modification time.

Creation time is supported by modern Linuxes but only through a new statx API which is not exposed by the Python standard library. There is a 0.1 version library from 2021 which exposes statx including the "birth time". I chose to raise an exception for now.

Each cloud does support a "modification time" but it generally refers to changes to metadata or is just the creation time:

@danking

danking commented Dec 27, 2022

Copy link
Copy Markdown
Contributor Author

I also just implemented RFC3339 parsing because Google's timestamps are not compliant with ISO8601.

def close(self):
self.aws.close()
async_to_blocking(self.cm.__aexit__())
async_to_blocking(self.cm.__aexit__(None, None, None))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Random other bug I found while I was in here.

Fixes hail-is#12540.

CHANGELOG: When using Query-on-Batch, hl.hadoop* methods now properly support creation and modification time.

Creation time is supported by modern Linuxes but only through a new statx API which is not
exposed by the Python standard library. There is a 0.1 version library from 2021 which exposes
statx including the "birth time". I chose to raise an exception for now.

Each cloud does support a "modification time" but it generally refers to changes to metadata or is just the creation time:
- https://cloud.google.com/storage/docs/json_api/v1/objects#resource (see updated)
- https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html#API_GetObject_ResponseSyntax ("Last-Modified", is always creation time)
- https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html#API_HeadObject_ResponseSyntax same as above
- https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob (see Last-Modified and x-ms-creation-time)
@danking

danking commented Jan 19, 2023

Copy link
Copy Markdown
Contributor Author

tests and lints resolved

jigold
jigold previously requested changes Jan 20, 2023
Comment thread hail/python/hailtop/aiotools/fs/fs.py Outdated
def time_modified(self) -> datetime.datetime:
'''The time the object was last modified in seconds since the epoch, UTC.

Not all clouds expose a modification time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you state what happens if the cloud doesn't expose a modification time?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll change the docs. In reality, every cloud supports modification time but it is just the creation time. The LocalFS does not support creation time except in very new *nix kernels.


def time_created(self) -> datetime.datetime:
# https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html#API_GetObject_ResponseSyntax
# Misleading name: LastModified is creation time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need to explicitly convert the result from the cloud provider into a Datetime object?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Amazon's Python API returns a datetime.datetime, mypy verifies this too.


if is_local:
try:
status.time_created()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we make sure we get the test for time_modified for the Local case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch

@danking danking left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

addressed


def time_created(self) -> datetime.datetime:
# https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html#API_GetObject_ResponseSyntax
# Misleading name: LastModified is creation time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Amazon's Python API returns a datetime.datetime, mypy verifies this too.

Comment thread hail/python/hailtop/aiotools/fs/fs.py Outdated
def time_modified(self) -> datetime.datetime:
'''The time the object was last modified in seconds since the epoch, UTC.

Not all clouds expose a modification time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll change the docs. In reality, every cloud supports modification time but it is just the creation time. The LocalFS does not support creation time except in very new *nix kernels.


if is_local:
try:
status.time_created()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch

@danking
danking merged commit 36e9cd4 into hail-is:main Feb 4, 2023
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.

hl.hadoop_stat no longer works for requester pays bucket

2 participants