versioning
versioning
¶
This module provides tools for managing resource versions.
Classes:
Name | Description |
---|---|
VersionManager |
manage the reading/writing of versions. |
VERSION_LIST_FILENAME = 'version_list.json'
module-attribute
¶
VersionManager
¶
A class to manage the reading/writing of versions.
Source code in nzssdt_2023/versioning/versioning.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
__init__(resource_folder: Optional[str] = None)
¶
Source code in nzssdt_2023/versioning/versioning.py
42 43 44 |
|
add(version_info: VersionInfo)
¶
add a version instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version_info
|
VersionInfo
|
the version_info instance. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
if the version_id already exists. |
Source code in nzssdt_2023/versioning/versioning.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
get(version_id: str) -> Union[VersionInfo, None]
¶
get a version, given a valid id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version_id
|
str
|
the version id string. |
required |
Returns:
Name | Type | Description |
---|---|---|
version_info |
Union[VersionInfo, None]
|
the version info instance |
Source code in nzssdt_2023/versioning/versioning.py
75 76 77 78 79 80 81 82 83 84 85 |
|
read_version_list() -> Dict[str, VersionInfo]
¶
return the version list as a dict.
Returns:
Name | Type | Description |
---|---|---|
version_dict |
Dict[str, VersionInfo]
|
a dictionary of version info instances. |
Source code in nzssdt_2023/versioning/versioning.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
remove(version_id: str) -> VersionInfo
¶
remove a version by version_id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version_id
|
str
|
the version id string. |
required |
Returns:
Name | Type | Description |
---|---|---|
version_info |
VersionInfo
|
the removed version info instance |
Source code in nzssdt_2023/versioning/versioning.py
118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
update(version_info: VersionInfo)
¶
update a version instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version_info
|
VersionInfo
|
the modified version instance. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
if the version_id was not found |
Source code in nzssdt_2023/versioning/versioning.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
write_version_list(new_list: Iterable[VersionInfo])
¶
write the version list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_list
|
Iterable[VersionInfo]
|
the list data to write to disk. |
required |
Source code in nzssdt_2023/versioning/versioning.py
66 67 68 69 70 71 72 73 |
|
ensure_resource_folders(version_id: str, exist_ok: bool = False)
¶
Source code in nzssdt_2023/versioning/versioning.py
23 24 25 26 27 28 29 |
|
standard_output_filename(version: Union[str, VersionInfo])
¶
Source code in nzssdt_2023/versioning/versioning.py
32 33 34 35 36 |
|
dataclass
¶
Dataclasses defining structures for versioning.
ConvertedFile
dataclass
¶
A dataclass defining a converted file.
NB not used from v2 on
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_filepath
|
str
|
path to the original file. |
required |
output_filepath
|
str
|
path to the output file. |
required |
Source code in nzssdt_2023/versioning/dataclass.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
IncludedFile
dataclass
¶
A dataclass defining a resource file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
path to the file. |
required |
Source code in nzssdt_2023/versioning/dataclass.py
31 32 33 34 35 36 37 38 39 40 |
|
VersionInfo
dataclass
¶
A dataclass defining the attributes of a NZSDDT version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version_id
|
str
|
a unique version number. |
required |
nzshm_model_version
|
str
|
the NSHM model version string. |
required |
description
|
Optional[str]
|
a versions description. |
None
|
conversions
|
List[ConvertedFile]
|
a list of files converted (from AH to versioned) TODO: not used in v2. |
list()
|
manifest
|
List[IncludedFile]
|
the data files used for reporting |
list()
|
reports
|
List[IncludedFile]
|
the reports files csv and PDF |
list()
|
nzshm_common_lib_version
|
str
|
the version of the nzshm_common library used to produce this version. |
nzshm_common.__version__
|
Source code in nzssdt_2023/versioning/dataclass.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
conversions: List[ConvertedFile] = field(default_factory=list)
class-attribute
instance-attribute
¶
description: Optional[str] = None
class-attribute
instance-attribute
¶
manifest: List[IncludedFile] = field(default_factory=list)
class-attribute
instance-attribute
¶
nzshm_common_lib_version: str = nzshm_common.__version__
class-attribute
instance-attribute
¶
nzshm_model_version: str
instance-attribute
¶
reports: List[IncludedFile] = field(default_factory=list)
class-attribute
instance-attribute
¶
version_id: str = field(hash=True)
class-attribute
instance-attribute
¶
__init__(version_id: str, nzshm_model_version: str, description: Optional[str] = None, conversions: List[ConvertedFile] = list(), manifest: List[IncludedFile] = list(), reports: List[IncludedFile] = list(), nzshm_common_lib_version: str = nzshm_common.__version__) -> None
¶
__str__()
¶
Source code in nzssdt_2023/versioning/dataclass.py
66 67 |
|
collect_manifest()
¶
Source code in nzssdt_2023/versioning/dataclass.py
77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
reports_path(reports_folder: Optional[str] = None) -> Path
¶
Source code in nzssdt_2023/versioning/dataclass.py
73 74 75 |
|
resource_path(resource_folder: Optional[str] = None) -> Path
¶
Source code in nzssdt_2023/versioning/dataclass.py
69 70 71 |
|