Skip to content

[ONE-Dockerizing] onecc-docker using recent version only#9722

Closed
morumoru wants to merge 0 commit intoSamsung:masterfrom
morumoru:master
Closed

[ONE-Dockerizing] onecc-docker using recent version only#9722
morumoru wants to merge 0 commit intoSamsung:masterfrom
morumoru:master

Conversation

@morumoru
Copy link
Contributor

introduce onecc-docker using recent version only

issue: #9721

Signed-off-by: Junsu Kim xofkdqkqh@naver.com

@morumoru morumoru added the SSAFY label Sep 16, 2022
@morumoru morumoru requested a review from jyoungyun September 16, 2022 03:04
@morumoru morumoru added the DRAFT A draft issue or PR for sharing one's current working status and discussion. label Sep 16, 2022
Comment on lines 3 to 6
RUN apt update -y && \
apt install -y \
wget && \
apt clean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RUN apt update -y && \
apt install -y \
wget && \
apt clean
RUN apt update -y && \
apt install -y wget && \
apt clean

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not use TABs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that this code don`t pass nacc format
I will check well before making pull request next time

apt clean
RUN wget https://github.com/Samsung/ONE/releases/download/1.20.0/one-compiler_1.20.0_amd64.deb && \
apt-get install -y ./one-compiler_1.20.0_amd64.deb
ENTRYPOINT ["onecc"] No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add new line here.
image
please check before posting PRs that you should not see these red circle.

@@ -0,0 +1,84 @@
#!/usr/bin/env bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to split this script and Docker files.
or can you explain the why Dockerfile and this file has close relation so that should be in one PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Dockerfile is not related with this script and I'll remove Dockerfile on next PR
We want to show people complete Dockerfile that this script will make but It was wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to show people complete Dockerfile that this script will make but It was wrong.

In this case, you can use a draft PR. A Draft PR is not for merging, so you can show whole files you want. :)

Copy link
Contributor

@jyoungyun jyoungyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add usage message. :)

I have some trouble to run this script because of samsung network issue.
In this case, I got the below error message:

$ ./onecc-docker 
403
rate limit exceeded
we can't get recent tag

In error situation, it would be good to write a detail message to make it easier for users to understand rather than simply printing a log. :)

@@ -0,0 +1,9 @@
FROM ubuntu:18.04
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM ubuntu:18.04
# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved
#
# 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.
FROM ubuntu:18.04

All codes should contain this samsung copyright. :)

Comment on lines 3 to 6
RUN apt update -y && \
apt install -y \
wget && \
apt clean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RUN apt update -y && \
apt install -y \
wget && \
apt clean
RUN apt-get update && apt-get install -qqy --no-install-recommends \
wget \
&& rm -rf /var/lib/apt/lists/*

from https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run

Comment on lines 7 to 8
RUN wget https://github.com/Samsung/ONE/releases/download/1.20.0/one-compiler_1.20.0_amd64.deb && \
apt-get install -y ./one-compiler_1.20.0_amd64.deb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RUN wget https://github.com/Samsung/ONE/releases/download/1.20.0/one-compiler_1.20.0_amd64.deb && \
apt-get install -y ./one-compiler_1.20.0_amd64.deb
RUN wget https://github.com/Samsung/ONE/releases/download/1.20.0/one-compiler_1.20.0_amd64.deb \
&& apt-get install -y ./one-compiler_1.20.0_amd64.deb \
&& rm -rf /var/lib/apt/lists/*

apt clean
RUN wget https://github.com/Samsung/ONE/releases/download/1.20.0/one-compiler_1.20.0_amd64.deb && \
apt-get install -y ./one-compiler_1.20.0_amd64.deb
ENTRYPOINT ["onecc"] No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ENTRYPOINT ["onecc"]
ENTRYPOINT ["onecc"]

@@ -0,0 +1,84 @@
#!/usr/bin/env bash
''''exec "python3" "onecc-docker" "$@" #'''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
''''exec "python3" "onecc-docker" "$@" #'''
''''exec "python3" "$0" "$@" #'''

@@ -0,0 +1,84 @@
#!/usr/bin/env bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add samsung copyright.

@jyoungyun
Copy link
Contributor

jyoungyun commented Sep 16, 2022

Before uploading a code, please check the code convention using ./nnas format ./compiler/onecc-docker. :)
I missed talking to you. :(

/cc @Samsung/ootpg

Comment on lines 35 to 45
def write_dockerfile(script_path,version) :

with open(f'{script_path}/Dockerfile', 'w', encoding='utf-8') as dockerfile:
dockerfile.write('FROM ubuntu:18.04 \n\n')
dockerfile.write('RUN apt update -y && \ \n')
dockerfile.write('\t apt install -y \ \n')
dockerfile.write('\t wget && \ \n')
dockerfile.write('\t apt clean \n')
dockerfile.write(f'RUN wget https://github.com/Samsung/ONE/releases/download/{version}/one-compiler_{version}_amd64.deb && \ \n')
dockerfile.write(f'\t apt-get install -y ./one-compiler_{version}_amd64.deb \n')
dockerfile.write('ENTRYPOINT ["onecc"]')
Copy link
Member

@holawan holawan Sep 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jyoungyun
Currently, we check the latest version of "ONE" with github api and dynamically create a Dockerfile. Is this all right? Or is it better to commit one Dockerfile statically and use it continuously?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way is good to me.

Another way I thought was to create static Dockerfile with declaring version as a variable, and update the variable in bash command.

I think both ways are worth trying.

However, what about using the static Dockerfile with the fixed version like you implemented before?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just parameterize the version with --build-arg option. Please see https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg for more detail.

@Seunghui98
Copy link
Contributor

@jyoungyun

Oh, thank you for code review. Is it better to commit push what has been modified through code review within the current PR #9722? Or should I put up a new PR?

@jyoungyun
Copy link
Contributor

Oh, thank you for code review. Is it better to commit push what has been modified through code review within the current #9722? Or should I put up a new PR?

What about taking one PR is for onecc-docker and another PR is for Dockerfile ?

@Seunghui98
Copy link
Contributor

@jyoungyun

Oh, thank you for your good opinion. As you advised, I will separate it into two PRs and upload it.

Comment on lines 49 to 50
onecc_version = subprocess.check_output("command -v onecc > /dev/null && echo $(onecc -v)", shell=True ,encoding='utf-8')
installed_onecc_version = onecc_version.split(' ')[2]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if users don't have any version of one-compiler installed?

Copy link
Contributor Author

@morumoru morumoru Sep 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that command -v onecc will return empty when onecc is not installed
but when I tested now, subprocess return nonzero exit status so It makes error on that. I'll change my code to care about absent of one-compiler.

onecc_version = subprocess.check_output("command -v onecc > /dev/null && echo $(onecc -v)", shell=True ,encoding='utf-8')
installed_onecc_version = onecc_version.split(' ')[2]

script_path = re.sub("\n", "", os.popen('pwd').read())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this one for better readability?

Suggested change
script_path = re.sub("\n", "", os.popen('pwd').read())
script_path = os.path.realpath(__file__)

print(response.reason)
print("we can't get recent tag")
exit(1)
else :
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need else syntax because above if always run exit.

Suggested change
else :

versions_json = json.loads(versions_str)
recent_version = versions_json[0]["name"]

if(recent_version == installed_onecc_version):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if condition works in the python script?

Suggested change
if(recent_version == installed_onecc_version):
if recent_version == installed_onecc_version:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed to erase parparentheses on my if statement.
It works on python script when I tested, but I'll erase parparentheses

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right it works. FYI, I think parentheses should be used only if it improves readability or you actually want to change the order of expression calculation.

@mhs4670go
Copy link
Collaborator

Do you have any plans for testing?

@holawan
Copy link
Member

holawan commented Sep 17, 2022

Do you have any plans for testing?

@mhs4670go

Our current test plan is as follows.

  • Test the viability of onecc-docker in various Linux environments (Red Hat, Ubuntu, CentOS, etc.)

  • Identify the docker version that will work as we intend (so that it can be used in as many versions as possible)

  • onecc related tests

    • Perform tests related to onecc in tests under one-compiler
    • Verify that the option to write to *.cfg, *.workflow.json works correctly

Our plan is not perfect.

@jyoungyun ,Can you give me a good opinion?

@jyoungyun
Copy link
Contributor

@jyoungyun ,Can you give me a good opinion?

At first, I thought it would be difficult to implement the test due to lack of time. However, even if the amount of implementation is reduced, implementing test codes seem to be a more complete way to write code. :)

I wrote a draft code related to test for your convenience. I didn't test it yet because it takes a lot of time to compile at first. :) What about supporting test codes by referring #9731.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DRAFT A draft issue or PR for sharing one's current working status and discussion. SSAFY

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants