Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# This file is part of daf_butler. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (http://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21 

22from __future__ import annotations 

23 

24__all__ = ["FileDataset"] 

25 

26from dataclasses import dataclass 

27from typing import ( 

28 Any, 

29 List, 

30 Optional, 

31 Union, 

32) 

33 

34 

35from .datasets import DatasetRef 

36from .formatter import FormatterParameter 

37 

38 

39@dataclass 

40class FileDataset: 

41 """A struct that represents a dataset exported to a file.""" 

42 

43 __slots__ = ("refs", "path", "formatter") 

44 

45 refs: List[DatasetRef] 

46 """Registry information about the dataset. (`list` of `DatasetRef`). 

47 """ 

48 

49 path: str 

50 """Path to the dataset (`str`). 

51 

52 If the dataset was exported with ``transfer=None`` (i.e. in-place), 

53 this is relative to the datastore root (only datastores that have a 

54 well-defined root in the local filesystem can be expected to support 

55 in-place exports). Otherwise this is relative to the directory passed 

56 to `Datastore.export`. 

57 """ 

58 

59 formatter: Optional[FormatterParameter] 

60 """A `Formatter` class or fully-qualified name. 

61 """ 

62 

63 def __init__(self, path: str, refs: Union[DatasetRef, List[DatasetRef]], *, 

64 formatter: Optional[FormatterParameter] = None): 

65 self.path = path 

66 if isinstance(refs, DatasetRef): 

67 refs = [refs] 

68 self.refs = refs 

69 self.formatter = formatter 

70 

71 def __lt__(self, other: Any) -> bool: 

72 # Sort on path alone 

73 if not isinstance(other, type(self)): 

74 return NotImplemented 

75 return self.path < other.path