-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This command produces JSON output to be consumed by shell scripts via the jq command.
- Loading branch information
1 parent
d3cae20
commit e52cb57
Showing
6 changed files
with
351 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import argparse | ||
import dataclasses | ||
import json | ||
import os | ||
import sys | ||
from typing import Any, Union | ||
|
||
from . import rapids_metadata | ||
from .metadata import ( | ||
RAPIDSMetadata, | ||
RAPIDSPackage, | ||
RAPIDSRepository, | ||
RAPIDSVersion, | ||
) | ||
from .rapids_version import get_rapids_version | ||
|
||
|
||
__all__ = [ | ||
"main", | ||
] | ||
|
||
|
||
class _RAPIDSMetadataEncoder(json.JSONEncoder): | ||
def default( | ||
self, o: Union[RAPIDSMetadata, RAPIDSPackage, RAPIDSRepository, RAPIDSVersion] | ||
) -> dict[str, Any]: | ||
return dataclasses.asdict(o) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--all-versions", action="store_true") | ||
|
||
parsed = parser.parse_args() | ||
metadata = ( | ||
rapids_metadata | ||
if parsed.all_versions | ||
else RAPIDSMetadata( | ||
versions={ | ||
get_rapids_version(os.getcwd()): rapids_metadata.get_current_version( | ||
os.getcwd() | ||
) | ||
} | ||
) | ||
) | ||
json.dump(metadata, sys.stdout, cls=_RAPIDSMetadataEncoder) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
Oops, something went wrong.