Skip to content

Commit

Permalink
[TentaclePackageMetadata] Add upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Herklos committed Jan 18, 2021
1 parent 08f5498 commit 09003c9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion octobot_tentacles_manager/api/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ async def create_tentacles_package(package_name: str,
should_cythonize=cythonize).export()
if upload_details is not None and len(upload_details) > 0:
export_path: str = tentacle_package.output_path
alias_name: str = upload_details[1] if len(upload_details) > 1 else os.path.basename(export_path)
alias_name: str = os.path.join(tentacle_package.version, os.path.basename(export_path))
metadata_file: str = os.path.join(os.path.dirname(export_path), constants.ARTIFACT_METADATA_FILE)
await uploader_api.upload_file_or_folder_to_nexus(nexus_path=upload_details[0],
artifact_path=export_path,
artifact_alias=alias_name)
await uploader_api.upload_file_or_folder_to_nexus(nexus_path=upload_details[0],
artifact_path=metadata_file,
artifact_alias=os.path.join(tentacle_package.version,
constants.ARTIFACT_METADATA_FILE))
return export_result


Expand Down
5 changes: 2 additions & 3 deletions octobot_tentacles_manager/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,8 @@ def register_tentacles_manager_arguments(tentacles_parser) -> None:
"pack commands. Usage: <nexus_path>",
nargs=1)
tentacles_parser.add_argument("-upe", "--upload-package-export", help="Upload package during export and "
"pack commands. "
"Usage: <nexus_path> [package_alias]",
nargs='+')
"pack commands. Usage: <nexus_path>",
nargs=1)
tentacles_parser.add_argument("-c", "--creator", help="Start OctoBot Tentacles Creator.\n Examples: -c Evaluator "
"to create a new evaluator tentacles. Use: -c help to get the"
" Tentacle Creator help.", nargs='+')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ async def get_metadata_instance(self) -> models.ArtifactMetadata:
if self.imported_metadata_file:
async with aiofiles.open(os.path.join(self.imported_metadata_file), "r") as imported_metadata_file:
metadata_instance.original_metadata_dict = yaml.safe_load(await imported_metadata_file.read())
metadata_instance.load_from_dict()
return metadata_instance
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def __init__(self, artifact: tentacle_package_model.TentaclePackage):
self.artifact_type: enums.ArtifactTypes = enums.ArtifactTypes.TENTACLE_PACKAGE
self.original_metadata_dict = None

def load_from_dict(self) -> None:
if self.original_metadata_dict:
if self.original_metadata_dict.get(constants.ARTIFACT_METADATA_VERSION):
self.artifact.version = self.original_metadata_dict.get(constants.ARTIFACT_METADATA_VERSION)

def to_dict(self) -> dict:
origin_dict = super().to_dict()
origin_dict[constants.ARTIFACT_METADATA_TENTACLES] = [
Expand Down

0 comments on commit 09003c9

Please sign in to comment.