[ONE-Dockerizing] Scripts that can run onecc using docker containers#9737
[ONE-Dockerizing] Scripts that can run onecc using docker containers#9737holawan wants to merge 9 commits intoSamsung:masterfrom
Conversation
This PR is a script that builds images and drives containers to run onecc with docker containers ONE-DCO-1.0.-Signed-off-by: Dongwan Kim <asdf134652@gmail.com>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
compiler/onecc-docker/onecc-docker
Outdated
| user_cmd = ''.join(sys.argv[1:]) | ||
| run_cmd = ["docker", "run", "--rm", "--name", contianer_name, "-v", "${HOME}:${HOME}", "-e", "HOME=${HOME}", "-w", work_dir, image_name, user_cmd] | ||
| cmd = ' '.join(run_cmd) | ||
| subprocess.run(cmd,shell=True) |
There was a problem hiding this comment.
In this onecc-docker, there are three method call when the subprocess is invoked - subprocess.run, subprocess.call, Popen. Is there a reason to use three different functions?
How about make a method that runs a command?
def run_subprocess(cmd):
ret = subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# do something or return the results
# error handling might be needed
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@mhs4670go , @jyoungyun |
Yes. Splitting the PR will split the information, which makes it difficult to find the history later. |
| import os | ||
| import requests | ||
|
|
||
|
|
There was a problem hiding this comment.
Could you add usage for this script? The argparse library will help you to write user friendly interfaces.
There was a problem hiding this comment.
You mean that make -h option on onecc-docker with argparse library?
I think that -h option is duplicated with onecc's -h option.
Should we make new flag for getting onecc's arguments?
There was a problem hiding this comment.
I think onecc-docker can take own argument. For example, if the user want to pass a personal access token to the request headers, onecc-docker should take a token value from argument. In view of this case, this script should implement a separate argparser.
There was a problem hiding this comment.
If onecc is already installed when running onecc-docker, shows onecc help message and if onecc is not installed, shows onecc-docker help message. What about this solution?
First of all, let's put the PR without considering -h option handling.
There was a problem hiding this comment.
If onecc is already installed when running onecc-docker, shows onecc help message and if onecc is not installed, shows onecc-docker help message. What about this solution?
Yes, after finalizing existing developments, it would be a good idea to consider them!
First of all, let's put the PR without considering -h option handling.
Okay.
compiler/onecc-docker/onecc-docker
Outdated
|
|
||
|
|
||
|
|
||
| def main(): |
There was a problem hiding this comment.
Unfortunately, I can't use the github rest api without authorization due to in-house network issue. So I suggest to support request header so that the users who need it can use it.
headers["Authorization"] = "token {}".format(/*token*/)
response = requests.get("https://api.github.com/repos/Samsung/ONE/tags", headers=headers)
https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting
https://docs.github.com/en/rest/overview/resources-in-the-rest-api#oauth2-token-sent-in-a-header
03b8873 to
07f9592
Compare
This PR has added error handling logic ONE-DCO-1.0.-Signed-off-by: Dongwan Kim <asdf134652@gmail.com>
This PR was created to add README to "onecc-docker". ONE-DCO-1.0.-Signed-off-by: Dongwan Kim <asdf134652@gmail.com>
| build_cmd = [ | ||
| "docker", "build", "-t", image_name, "--build-arg", build_arg, script_path | ||
| ] | ||
| print('build Docker image ...') | ||
| _run(build_cmd) | ||
| print('Dockerfile successfully built.') |
There was a problem hiding this comment.
@jyoungyun , when the user does not have a docker image, the build time takes about 10 minutes. Is it necessary to print out the flow of the docker being built?
There was a problem hiding this comment.
Yes, I think it is necessary.
This PR has added an API request excess exception handling code ONE-DCO-1.0.-Signed-off-by: Dongwan Kim <asdf134652@gmail.com>
compiler/onecc-docker/README.md
Outdated
| @@ -0,0 +1,263 @@ | |||
| # onecc-docker | |||
|
|
|||
| `onecc-docker` supports `one-cmd`, which is currently only supported by ubuntu 18.04, in more OS. | |||
There was a problem hiding this comment.
`onecc-docker` -> _onecc-docker_
| `onecc-docker` supports `one-cmd`, which is currently only supported by ubuntu 18.04, in more OS. | |
| _onecc-docker_ supports `one-cmds`, which is currently only supported on ubuntu 18.04, in more OS. |
There was a problem hiding this comment.
Q) what is in more OS. ?
There was a problem hiding this comment.
Q) what is in more OS. ?
More OSs can provide it.
There was a problem hiding this comment.
only supported on ... in more OS.
I cann't catch the meaning of this sentense. can you elaborate a bit?
There was a problem hiding this comment.
This means that onecc-docker supports running onecc in environments other than ubuntu:18.04.
There was a problem hiding this comment.
How about
- onecc-docker can expand
one-cmdsin more platforms than just Ubuntu 18.04/20.04. - or
- We can use
one-cmdsin more platorms than just Ubuntu 18.04/20.04 through onecc-docker.
| import json | ||
| import os | ||
| import requests | ||
| import argparse |
There was a problem hiding this comment.
This argparse has been added for https://github.com/Samsung/ONE/pull/9737/files#r974949214. Is it going to be used?
There was a problem hiding this comment.
We haven't started the task on "argparse" yet.
I am trying to use it according to @jyoungyun's opinion.
I think I can give you a detailed answer after the meeting tomorrow.
There was a problem hiding this comment.
Could you add token argument for in-house developers?
| import os | ||
| import requests | ||
|
|
||
|
|
There was a problem hiding this comment.
If onecc is already installed when running onecc-docker, shows onecc help message and if onecc is not installed, shows onecc-docker help message. What about this solution?
First of all, let's put the PR without considering -h option handling.
| import json | ||
| import os | ||
| import requests | ||
| import argparse |
There was a problem hiding this comment.
Could you add token argument for in-house developers?
| build_cmd = [ | ||
| "docker", "build", "-t", image_name, "--build-arg", build_arg, script_path | ||
| ] | ||
| print('build Docker image ...') | ||
| _run(build_cmd) | ||
| print('Dockerfile successfully built.') |
There was a problem hiding this comment.
Yes, I think it is necessary.
compiler/onecc-docker/onecc-docker
Outdated
| response = requests.get(TAG_URL) | ||
| response.raise_for_status() | ||
| except requests.exceptions.RequestException as e: | ||
| raise SystemExit(e) |
There was a problem hiding this comment.
Could you user-friendly print an error message?
SystemExit('blah blah blah')
There was a problem hiding this comment.
When error occured in requests for example "401 Client Error: Unauthorized for url: https://api.github.com/repos/Samsung/ONE/releases/latest" message is printed to bash (Git api sent this message from server)
Should I print more information except this?
There was a problem hiding this comment.
Yes. I think the message is not friendly to the users. :)
You can see some error messages in https://github.com/Samsung/ONE/blob/master/compiler/one-cmds/utils.py file.
There was a problem hiding this comment.
Thank you for advice! I'll check utils.py.
|
|
||
|
|
||
|
|
||
| ## Examples |
There was a problem hiding this comment.
What about separating this content into a separate file like tutorial.md?
|
@jyoungyun , we will proceed with code refactoring by collecting your opinions. If our code has been fixed and you think it's okay to merge, can you please tell me? |
compiler/onecc-docker/README.md
Outdated
| ## Description | ||
|
|
||
| For now, `one-cmds` tools only support Ubuntu 18.04 and 20.04(not officially). | ||
| So people in other environments can't use our tools unless they upgrade the OS (or install Ubuntu OS). |
There was a problem hiding this comment.
they upgrade the OS
Actually, users may use recent Ubutuntu 22.04. Thus it is likely they downgrade the OS
There was a problem hiding this comment.
Actually, users may use recent Ubutuntu 22.04. Thus it is likely they downgrade the OS
How about changing it like this?
Therefore, it is difficult for people in different environments to use our tools without using ubuntu18:04.
compiler/onecc-docker/README.md
Outdated
| ### Check Docker Image Presence and Build Image | ||
|
|
||
| - To prevent repetitive image generation, we verify that there is an `onecc` image of the latest `one` release version. | ||
| - If not, build the docker image using the docker file. |
There was a problem hiding this comment.
In my opinion, we build the docker image only once (unless the user intentionally deletes the image), what we repeat is considered to be the creation and deletion of the container.
@jyoungyun
What do you think?
There was a problem hiding this comment.
build->rebuild?
@seanshpark I can't catch your intention. :( Could you explain more?
The docker image is built only once there is no image with the same name. So I think build is more suitable for this step...
There was a problem hiding this comment.
Well, this maybe because I'm not a good Docker user/developer.
What I see is a Docker image. from the explanation, when the latest is changed, it sounds like Docker image is built again. So from the though of again, it looks like rebuild.
Technically it looks like build not rebuild so, we can go with build
| 0 directories, 6 files | ||
| ``` | ||
|
|
||
| #### `-h` ,`--help` |
There was a problem hiding this comment.
Do you mean help message only for onecc-docker? This is under discussion with @jyoungyun .
There was a problem hiding this comment.
Let's discuss after the code supporting the input arguments is shared. :)
Of course. If there is nothing more to modify, I will let you know. :) |
This PR has added README fixes and Tutorial ONE-DCO-1.0.-Signed-off-by: Dongwan Kim <asdf134652@gmail.com>
This PR has added argmentParser to onecc-docker ONE-DCO-1.0.-Signed-off-by: Junsu Kim <xofkdqkqh@naver.com>
This PR is a script that builds images and drives containers to run onecc with docker containers
ONE-DCO-1.0.-Signed-off-by: Dongwan Kim asdf134652@gmail.com
This PR is an improved script to reflect the review
This PR has added error handling logic
This PR was created to add README to "onecc-docker".
This PR has added an API request excess exception handling code
parent issue: #9712 #9721
draft: #9722
/cc @Samsung/ootpg