From c62e0ca28829b06c59b0d4d9be4d375d9ca81e42 Mon Sep 17 00:00:00 2001 From: Akilan Date: Mon, 24 May 2021 12:39:57 +0400 Subject: [PATCH 1/6] current changes in ansible runs --- deploy/README.md | 1 + server/docker/docker_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy/README.md b/deploy/README.md index 9cd45d1..7b4b26a 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -1,4 +1,5 @@ # Ansible p2p-rendering-computation +### Modified from: This repository contains an Ansible playbook and instructions to create and manage a single (or many) bare metal deep learning machines. For a description of why Ansible was chosen and what other alternatives were considered, please see [ToolSelection.md](ToolSelection.md) diff --git a/server/docker/docker_test.go b/server/docker/docker_test.go index e09cc11..50f39b7 100644 --- a/server/docker/docker_test.go +++ b/server/docker/docker_test.go @@ -7,7 +7,7 @@ import ( func TestDocker(t *testing.T) { //TODO overwrite with custom docker paths - resp,err := BuildRunContainer(2,"false") + resp,err := BuildRunContainer(2,"true") if err != nil { t.Error(err) From 65e633e6c4440c797649db21ecf27c7b5f1e7aa0 Mon Sep 17 00:00:00 2001 From: Akilan Date: Mon, 24 May 2021 12:50:34 +0400 Subject: [PATCH 2/6] removed .idea file --- .gitignore | 1 + .idea/.gitignore | 8 -------- .idea/modules.xml | 8 -------- .idea/p2p-redering-computation.iml | 15 --------------- .idea/p2p-rendering-computation.iml | 8 -------- .idea/vcs.xml | 6 ------ 6 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/modules.xml delete mode 100644 .idea/p2p-redering-computation.iml delete mode 100644 .idea/p2p-rendering-computation.iml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 0df29a4..9d95a8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea vendor/ bin/ p2p-rendering/ diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 73f69e0..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 935e4b3..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/p2p-redering-computation.iml b/.idea/p2p-redering-computation.iml deleted file mode 100644 index e28edd5..0000000 --- a/.idea/p2p-redering-computation.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/p2p-rendering-computation.iml b/.idea/p2p-rendering-computation.iml deleted file mode 100644 index c956989..0000000 --- a/.idea/p2p-rendering-computation.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From f89e7ccbcba549da2a522576c46b32af56df75dd Mon Sep 17 00:00:00 2001 From: Akilan Date: Mon, 24 May 2021 13:58:24 +0400 Subject: [PATCH 3/6] added fix for removing elements from the array --- go.mod | 1 + go.sum | 1 + p2p/ip_table.json | 15 +-------------- p2p/speedtest.go | 12 +++++++++--- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 44e04c7..f693d0a 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect golang.org/x/text v0.3.5 // indirect golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect + golang.org/x/tools v0.0.0-20210106214847-113979e3529a google.golang.org/grpc v1.35.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gotest.tools/v3 v3.0.3 // indirect diff --git a/go.sum b/go.sum index 5a2b02b..f3bf854 100644 --- a/go.sum +++ b/go.sum @@ -820,6 +820,7 @@ golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/p2p/ip_table.json b/p2p/ip_table.json index ce8de32..e8729ed 100644 --- a/p2p/ip_table.json +++ b/p2p/ip_table.json @@ -1,16 +1,3 @@ { - "ip_address": [ - { - "ipv4": "147.75.100.225", - "latency": 1582411, - "download": 279180.07603469375, - "upload": 855366.1394760027 - }, - { - "ipv4": "86.99.70.106", - "latency": 134446840, - "download": 1582.176490711659, - "upload": 597823.3252726822 - } - ] + "ip_address": null } \ No newline at end of file diff --git a/p2p/speedtest.go b/p2p/speedtest.go index b5fad69..6a49074 100644 --- a/p2p/speedtest.go +++ b/p2p/speedtest.go @@ -8,9 +8,9 @@ func (ip *IpAddresses)SpeedTest() error{ for i, value := range ip.IpAddress { var err error - if len(ip.IpAddress) == 1 { - i = 0 - } + //if len(ip.IpAddress) == 1 { + // i = 0 + //} // Ping Test err = value.PingTest() @@ -40,6 +40,12 @@ func (ip *IpAddresses)SpeedTest() error{ } // Remove element from struct for _, index := range RemoveIndex { + // If there is only 1 element and that has to be + // removed + if len(ip.IpAddress) == 1 { + ip.IpAddress = nil + break + } ip.IpAddress = append(ip.IpAddress[:index], ip.IpAddress[index+1:]...) } From 49cd37624fdbcbe6556c8bad2b24f042527dd53f Mon Sep 17 00:00:00 2001 From: Akilan Date: Mon, 24 May 2021 20:52:06 +0400 Subject: [PATCH 4/6] fixed issues regarding viper and possibility of cli --- .gitignore | 1 + Makefile | 11 ++++++++--- config/config.go | 40 +++++++++++++++++++++++----------------- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 9d95a8d..9416a36 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ p2p-rendering/ main server/docker/__pycache__ p2p-rendering-computation +p2prc config.json diff --git a/Makefile b/Makefile index dcb8290..a2ff861 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,16 @@ SHELL := /bin/bash install: - go build . - ./p2p-rendering-computation --SetDefaultConfig + go build -o p2prc + echo '# Paths for p2p rendering and computation' >> ~/.bashrc + echo 'export P2PRC=${PWD}' >> ~/.bashrc + echo 'export ${PWD}:$${PATH}' >> ~/.bashrc + source ~/.bashrc + ./p2prc --SetDefaultConfig + build: - go build . + go build -o p2prc config: ./p2p-rendering-computation --SetDefaultConfig diff --git a/config/config.go b/config/config.go index 707b103..b30a11d 100644 --- a/config/config.go +++ b/config/config.go @@ -12,7 +12,7 @@ var ( "DockerFile": "/home/akilan/Documents/p2prendering/p2p-redering-computation/server/docker/containers/docker-ubuntu-sshd/", "SpeedTestFile":"/etc/p2p-rendering/50.bin", } - configName = "config.json" + configName = "config" configType = "json" configFile = "config.json" configPaths []string @@ -37,11 +37,8 @@ func fileExists(name string) bool { // SetDefaults This function to be called only during a // make install func SetDefaults() error { - //Getting Current Directory - curDir, err := os.Getwd() - if err != nil { - return err - } + //Getting Current Directory from environment variable + curDir := os.Getenv("P2PRC") //Setting current directory to default path defaultPath = curDir + "/" @@ -62,7 +59,7 @@ func SetDefaults() error { } //Calling configuration file - _, err = ConfigInit() + _, err := ConfigInit() if err != nil { return err } @@ -70,23 +67,32 @@ func SetDefaults() error { } func ConfigInit()(*Config,error) { - //Sets default configuration to viper - for k,v := range defaults { - viper.SetDefault(k,v) - } - viper.SetConfigName(configName) - viper.SetConfigFile(configFile) - viper.SetConfigType(configType) + + curDir := os.Getenv("P2PRC") + //Setting current directory to default path + defaultPath = curDir + "/" + //Paths to search for config file + configPaths = append(configPaths, defaultPath) + //Add all possible configurations paths for _,v := range configPaths { viper.AddConfigPath(v) } + //Read config file if err := viper.ReadInConfig(); err != nil { // If the error thrown is config file not found - if err = viper.WriteConfig(); err != nil { - return nil,err - } + //Sets default configuration to viper + for k,v := range defaults { + viper.SetDefault(k,v) + } + viper.SetConfigName(configName) + viper.SetConfigFile(configFile) + viper.SetConfigType(configType) + + if err = viper.WriteConfig(); err != nil { + return nil,err + } } // Adds configuration to the struct From cbe6e682d20015304ab6c7b1a5bb5b4bcc7a3342 Mon Sep 17 00:00:00 2001 From: Akilan Date: Mon, 24 May 2021 20:54:17 +0400 Subject: [PATCH 5/6] updated docs --- Docs/Installation.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Docs/Installation.md b/Docs/Installation.md index a5cb1c5..f54f942 100644 --- a/Docs/Installation.md +++ b/Docs/Installation.md @@ -13,6 +13,7 @@ in the developer community. In the server module we use the Docker Go API to cre interact with the containers. [Instructions to install docker](https://docs.docker.com/get-docker/) + [Instructions to install docker GPU](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker) ```` Do ensure that the docker command does not need sudo to run @@ -27,7 +28,7 @@ make install ### Test if binary works ``` -./p2p-rendering-computation --help +p2prc --help ``` #### Output: ``` @@ -60,10 +61,6 @@ GLOBAL OPTIONS: ``` -### Add command to .bashrc or .zshrc -``` -export PATH=~//p2p-redering-computation:${PATH} -``` #### Note: The steps on how to use the commands will be added later. From 14aeaa7e1ac064f4587e843b8053af9420327f50 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar <31743758+Akilan1999@users.noreply.github.com> Date: Mon, 24 May 2021 23:51:57 +0400 Subject: [PATCH 6/6] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a2ff861..28bd493 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ install: go build -o p2prc echo '# Paths for p2p rendering and computation' >> ~/.bashrc echo 'export P2PRC=${PWD}' >> ~/.bashrc - echo 'export ${PWD}:$${PATH}' >> ~/.bashrc + echo 'export path=${PWD}:$${PATH}' >> ~/.bashrc source ~/.bashrc ./p2prc --SetDefaultConfig