diff --git a/.gitignore b/.gitignore index bb15a08..531dfcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ +.idea vendor/ bin/ p2p-rendering/ main server/docker/__pycache__ p2p-rendering-computation +p2prc config.json .vscode/ \ No newline at end of file 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 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. diff --git a/Makefile b/Makefile index dcb8290..28bd493 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 path=${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 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/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:]...) } 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)