-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- New APIs - `Artifact.image_name` property - `Artifact.push` method - Documentations update - New notebook for handling OMMX Artifact
- Loading branch information
Showing
11 changed files
with
374 additions
and
50 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,155 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ec41c28b-5d3f-4e6c-a76a-bae41a57186f", | ||
"metadata": {}, | ||
"source": [ | ||
"# Create OMMX Artifact" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "f8fe903b-8acd-40dc-9263-7c5f9197876d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import uuid # To generate random tag for testing\n", | ||
"import logging # To see the log of pushing artifact\n", | ||
"logging.basicConfig(level=logging.INFO)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "57b9e174-2c4c-444a-9ea7-d0ab6f112162", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ommx.artifact import Artifact, ArtifactBuilder\n", | ||
"from ommx.testing import SingleFeasibleLPGenerator, DataType" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a2779a4a-4f76-4c77-a2e2-c64d5a4c2aff", | ||
"metadata": {}, | ||
"source": [ | ||
"## Ready `ommx.v1.Instance` to be packed into artifact" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "4be947b0-95c5-477b-8c7e-d2501c03a2d8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"generator = SingleFeasibleLPGenerator(3, DataType.INT)\n", | ||
"instance = generator.get_v1_instance()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "cb3adc3e-483d-4c4a-96fc-23888a43e1f1", | ||
"metadata": {}, | ||
"source": [ | ||
"## Build OMMX artifact" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "00061527-a0ee-4b78-8727-8472c27cac7e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"builder = ArtifactBuilder.for_github(\n", | ||
" \"Jij-Inc\", # GitHub organization\n", | ||
" \"ommx\", # Repository name\n", | ||
" \"single_feasible_lp\", # Name of artifact\n", | ||
" str(uuid.uuid4()) # Tag of artifact\n", | ||
")\n", | ||
"builder.add_instance(instance)\n", | ||
"artifact = builder.build()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "5374f4f4-1d6f-44b4-83f2-8056f349a36c", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'ghcr.io/jij-inc/ommx/single_feasible_lp:4c09b065-a55c-4358-8083-9ce3db3b6e6c'" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"artifact.image_name" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a04b993d-d13c-4fba-83fc-677da7d6543d", | ||
"metadata": {}, | ||
"source": [ | ||
"## Push artifact to container registry\n", | ||
"\n", | ||
"- This artifact will be pushed to <https://github.com/Jij-Inc/ommx/pkgs/container/ommx%2Fsingle_feasible_lp>\n", | ||
"- `push` requires authentication using personal access token (PAT) or `GITHUB_TOKEN` on GitHub Actions." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "a06ef2f5-595f-485a-9ca9-11923278123b", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"INFO:ommx.artifact:Pushing: ghcr.io/jij-inc/ommx/single_feasible_lp:4c09b065-a55c-4358-8083-9ce3db3b6e6c\n", | ||
"INFO:ocipkg.distribution.client:POST https://ghcr.io/v2/jij-inc/ommx/single_feasible_lp/blobs/uploads/\n", | ||
"INFO:ocipkg.distribution.client:PUT https://ghcr.io/v2/jij-inc/ommx/single_feasible_lp/blobs/upload/ebb244fb-38e4-4472-b460-932b43569344\n", | ||
"INFO:ocipkg.distribution.client:POST https://ghcr.io/v2/jij-inc/ommx/single_feasible_lp/blobs/uploads/\n", | ||
"INFO:ocipkg.distribution.client:PUT https://ghcr.io/v2/jij-inc/ommx/single_feasible_lp/blobs/upload/09b62410-7376-4cbe-bfc2-aaac66736b43\n", | ||
"INFO:ocipkg.distribution.client:PUT https://ghcr.io/v2/jij-inc/ommx/single_feasible_lp/manifests/4c09b065-a55c-4358-8083-9ce3db3b6e6c\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"artifact.push()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.