-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
DataChain.listings()
method and use it in getting storages (#331)
* first version of from_storage without deprecated listing * first version of from_storage without deprecated listing * fixing tests and removing prints, refactoring * refactoring listing static methods * fixing non recursive queries * using ctc in test session * fixing json * added DataChain.listings classmethod that returns list of ListingInfo objects for each cached listing * another test for listings * removed not needed filters * refactoring test * removed not needed catalog storage methods and their related codebase * fixing windows tests * returning to all tests * removed unlist_source method and related codebase * fixing dataset dependencies * added session on cloud test catalog and refactoring tests * using new listings method in from_storage * fixing test * fixing test * added dataset name dependencies test and fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * small refactoring * refactor comments --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
944029b
commit 576b69a
Showing
18 changed files
with
282 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from datetime import datetime, timedelta, timezone | ||
from typing import Optional | ||
|
||
from datachain.client import Client | ||
from datachain.lib.dataset_info import DatasetInfo | ||
from datachain.lib.listing import LISTING_PREFIX, LISTING_TTL | ||
|
||
|
||
class ListingInfo(DatasetInfo): | ||
@property | ||
def uri(self) -> str: | ||
return self.name.removeprefix(LISTING_PREFIX) | ||
|
||
@property | ||
def storage_uri(self) -> str: | ||
client, _ = Client.parse_url(self.uri, None) # type: ignore[arg-type] | ||
return client.uri | ||
|
||
@property | ||
def expires(self) -> Optional[datetime]: | ||
if not self.finished_at: | ||
return None | ||
return self.finished_at + timedelta(seconds=LISTING_TTL) | ||
|
||
@property | ||
def is_expired(self) -> bool: | ||
return datetime.now(timezone.utc) > self.expires if self.expires else False | ||
|
||
@property | ||
def last_inserted_at(self): | ||
# TODO we need to add updated_at to dataset version or explicit last_inserted_at | ||
raise NotImplementedError |
Oops, something went wrong.