Skip to content

Commit

Permalink
Make minor changes in Dockerfile.
Browse files Browse the repository at this point in the history
Fix IS_WRITE in mongodb disabling writing in all functions.
  • Loading branch information
avatar-lavventura committed Apr 6, 2023
1 parent 1c9ab11 commit 95f2e63
Show file tree
Hide file tree
Showing 21 changed files with 115 additions and 74 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# syntax=docker/dockerfile:1
FROM golang:latest
RUN apt-get install -y ca-certificates
RUN wget --no-check-certificate -q "https://dist.ipfs.io/go-ipfs/v0.19.0/go-ipfs_v0.19.0_linux-amd64.tar.gz" \
&& tar -xf "go-ipfs_v0.19.0_linux-amd64.tar.gz" \
&& rm -f go-ipfs_v0.19.0_linux-amd64.tar.gz \
ARG IPFS_TAG=v0.19.0
RUN wget --no-check-certificate -q "https://dist.ipfs.io/go-ipfs/"${IPFS_TAG}"/go-ipfs_"${IPFS_TAG}"_linux-amd64.tar.gz" \
&& tar -xf "go-ipfs_"${IPFS_TAG}"_linux-amd64.tar.gz" \
&& rm -f go-ipfs_${IPFS_TAG}_linux-amd64.tar.gz \
&& cd go-ipfs \
&& make install \
&& ./install.sh
Expand Down Expand Up @@ -89,6 +90,7 @@ ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /workspace
RUN git clone https://github.com/ebloc/ebloc-broker.git
WORKDIR /workspace/ebloc-broker

#: `pip install -e .` takes few minutes
RUN git checkout dev >/dev/null 2>&1 \
&& git fetch --all --quiet >/dev/null 2>&1 \
Expand Down
10 changes: 10 additions & 0 deletions broker/.todo.org_archive
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,13 @@ E: Error: connect 12D3KooWQ9eXnXRs5MeCP11tgvcWENsUs4JUMBBESfDX3QDGf548 failurfai
* /ip4/68.183.79.44/tcp/4001 failed to negotiate security protocol: peer id mismatch: expected 12D3KooWQ9eXnXRs5MeCP11tgvcWENsUs4JUMBBESfDX3QDGf548, but remote key matches
12D3KooWP77QwRFYkEeat23hGNdDQ36VyCiEP56RaRf585QzauTD
#+end_src

* DONE during job submittion check web3 connection
CLOSED: [2023-04-05 Wed 15:45]
:PROPERTIES:
:ARCHIVE_TIME: 2023-04-05 Wed 15:45
:ARCHIVE_FILE: ~/ebloc-broker/broker/todo.org
:ARCHIVE_OLPATH: TASKS
:ARCHIVE_CATEGORY: todo
:ARCHIVE_TODO: DONE
:END:
10 changes: 7 additions & 3 deletions broker/Driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def run_driver(given_bn):
f"==> account_balance={math.floor(gwei_balance)} [blue]gwei[/blue] ≈ "
f"{format(cfg.w3.fromWei(wei_amount, 'ether'), '.2f')} [blue]ether"
)
log(f"==> Ebb_token_balance={Cent(balance_temp)._to()} [blue]usd")
log(f"==> Overall Ebb_token_balance={Cent(balance_temp)._to()} [blue]usd")
slurm.pending_jobs_check()
first_iteration_flag = True
while True:
Expand All @@ -422,7 +422,7 @@ def run_driver(given_bn):
if not first_iteration_flag:
console_ruler()
if isinstance(balance, int):
cc = Cent(int(balance) - int(balance_temp))._to()
cc = Cent(int(balance) - int(env.config["token_balance"]))._to()
log(f"==> since driver started provider_gained_token={cc} usd")

current_bn = Ebb.get_block_number()
Expand Down Expand Up @@ -488,7 +488,11 @@ def reconnect():

def check_connection():
if not network.is_connected():
reconnect()
try:
reconnect()
except Exception as e:
log(f"E: {e}")

if not network.is_connected():
time.sleep(15)
else:
Expand Down
Empty file modified broker/Pidfile.py
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion broker/_cli/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def my_inline_function():

app = VulcanoApp()
Ebb = cfg.Ebb
_log.IS_WRITE = False
_log.IS_WRITE = False # applies this all libs imported this
t1 = threading.Thread(target=my_inline_function)
t1.start()

Expand Down
7 changes: 5 additions & 2 deletions broker/_utils/_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
install() # for rich, show_locals=True
# pretty.install()

IS_WRITE = True # if False disable write into file for the process
# if False disable write into file for the process
# heads up applies this all libs imported this
IS_WRITE = True

DRIVER_LOG = None
IS_THREADING_MODE_PRINT = False
thread_log_files: Dict[str, str] = {}
Expand Down Expand Up @@ -157,7 +160,7 @@ def br(text, color="white"):


def ok():
return " " + br(" [g]OK[/g] ")
return " " + br(" [g]OK[/g] ")


def _console_clear():
Expand Down
2 changes: 1 addition & 1 deletion broker/_utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def squeue() -> None:
if len(f"{squeue_output}\n".split("\n", 1)[1]) > 0:
# checks if the squeue output's line number is gretaer than 1
# log("view information about jobs located in the Slurm scheduling queue:", "yellow")
log(f"{squeue_output}{ok()}\n")
log(f"{squeue_output} {ok()}\n")


def compare_files(fn1, fn2) -> bool:
Expand Down
61 changes: 33 additions & 28 deletions broker/bash_scripts/clean_for_new_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,28 @@ for user in $(members eblocbroker | tr " " "\n"); do
done

BASE="/var/ebloc-broker"
mkdir -p $BASE/to_delete

mv $BASE/* $BASE/to_delete >/dev/null 2>&1
DIR=$BASE/to_delete/public
[ -d $DIR ] && mv $BASE/to_delete/public $BASE/

DIR=$BASE/to_delete/cache # do not delete files in /var/ebloc-broker/cache/
[ -d $DIR ] && mv $DIR $BASE/

FILE=$BASE/to_delete/slurm_mail_prog.sh # recover slurm_mail_prog.sh
[ -f $FILE ] && mv $FILE $BASE/
if [[ -d $BASE ]]; then
mkdir -p $BASE/to_delete

mv $BASE/* $BASE/to_delete >/dev/null 2>&1
DIR=$BASE/to_delete/public
[ -d $DIR ] && mv $BASE/to_delete/public $BASE/

DIR=$BASE/to_delete/cache # do not delete files in /var/ebloc-broker/cache/
[ -d $DIR ] && mv $DIR $BASE/

FILE=$BASE/to_delete/slurm_mail_prog.sh # recover slurm_mail_prog.sh
[ -f $FILE ] && mv $FILE $BASE/

find /var/ebloc-broker/to_delete -name "*data_link*" | while read -r i
do
sudo umount -f $i/* >/dev/null 2>&1
done
sudo rm -rf $BASE/to_delete
rm -f /var/ebloc-broker/cache/*.tar.gz
mkdir -p $BASE/cache
fi

find /var/ebloc-broker/to_delete -name "*data_link*" | while read -r i
do
sudo umount -f $i/* >/dev/null 2>&1
done
sudo rm -rf $BASE/to_delete
rm -f /var/ebloc-broker/cache/*.tar.gz
mkdir -p $BASE/cache
find $HOME/.ebloc-broker/*/* -mindepth 1 ! \
-regex '^./private\(/.*\)?' -delete >/dev/null 2>&1

Expand All @@ -62,11 +65,11 @@ rm -f $HOME/.ebloc-broker/ipfs.out
rm -f $HOME/.ebloc-broker/ganache.out
rm -f $HOME/.ebloc-broker/*.yaml~

rm -f $BASE/geth_server.out
rm -f $BASE/.node-xmlhttprequest*
rm -f $BASE/ipfs.out
rm -f $BASE/modified_date.txt
rm -f $BASE/package-lock.json
rm -f $HOME/.ebloc-broker/geth_server.out
rm -f $HOME/.ebloc-broker/.node-xmlhttprequest*
rm -f $HOME/.ebloc-broker/ipfs.out
rm -f $HOME/.ebloc-broker/modified_date.txt
rm -f $HOME/.ebloc-broker/package-lock.json

rm -rf ~/ebloc-broker/contract/build
rm -rf ~/ebloc-broker/contract/reports
Expand All @@ -91,10 +94,12 @@ done

if [ "$(hostname)" = "homevm" ]; then
echo "#> ln datasets for homevm"
~/ebloc-broker/broker/test_setup/ln_medium_data.sh
~/ebloc-broker/broker/bash_scripts/ln_medium_data.sh
fi

echo -e "\n/var/ebloc-broker/"
CURRENT_DIR=$PWD
cd /var/ebloc-broker && fdfind . | as-tree && cd ~
cd $CURRENT_DIR
if [[ -d $BASE ]]; then
echo -e "\n/var/ebloc-broker/"
CURRENT_DIR=$PWD
cd /var/ebloc-broker && fdfind . | as-tree && cd ~
cd $CURRENT_DIR
fi
File renamed without changes.
3 changes: 2 additions & 1 deletion broker/eblocbroker_scripts/Contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from contextlib import suppress
from os.path import expanduser
from typing import Union
from broker.imports import nc

from halo import Halo
from pymongo import MongoClient
from web3.exceptions import TransactionNotFound
Expand All @@ -19,6 +19,7 @@
from broker._utils.yaml import Yaml
from broker.config import env
from broker.errors import QuietExit, Web3NotConnected
from broker.imports import nc
from broker.libs.mongodb import MongoBroker
from broker.utils import ipfs_to_bytes32, terminate
from brownie.network.account import Account, LocalAccount
Expand Down
3 changes: 3 additions & 0 deletions broker/eblocbroker_scripts/get_block_number.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

from broker.eblocbroker_scripts.utils import Cent
import sys

from broker import cfg
Expand All @@ -21,6 +22,8 @@ def main():
output = Ebb.get_block_number()
if is_write_to_file:
env.config["block_continue"] = output
balance_temp = Ebb.get_balance(env.PROVIDER_ID)
env.config["token_balance"] = int(balance_temp)
else:
log(f"block_number={output}")
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion broker/gdrive/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _submit(job, provider, key, requester, required_confs):
processed_logs = Ebb._eblocbroker.events.LogJob().processReceipt(tx_receipt, errors=DISCARD)
log(vars(processed_logs[0].args))
try:
log(f"job_index={processed_logs[0].args['index']}{ok()}", "bold")
log(f"job_index={processed_logs[0].args['index']} {ok()}")
except IndexError:
log(f"E: Tx({tx_hash}) is reverted")
except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions broker/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys
from contextlib import suppress

from broker import cfg, config
from broker._utils.tools import log, print_tb, read_json, run
from broker.config import env
Expand Down
4 changes: 2 additions & 2 deletions broker/libs/eudat.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def share_single_folder(folder_name, f_id):
"""Share given folder path with the user."""
if not config.oc.is_shared(folder_name):
config.oc.share_file_with_user(folder_name, f_id, remote_user=True, perms=31)
log(f"sharing with [yellow]{f_id}[/yellow]{ok()}")
log(f"sharing with [yellow]{f_id}[/yellow] {ok()}")

log("## Requester folder is already shared")

Expand Down Expand Up @@ -240,7 +240,7 @@ def submit(provider, requester, job, required_confs=1):
log(vars(processed_logs[0].args))
try:
processed_logs[0].args["index"]
# log(f"[bold]job_index={processed_logs[0].args['index']}{ok()}")
# log(f"[bold]job_index={processed_logs[0].args['index']} {ok()}")
except IndexError:
log(f"E: Tx({tx_hash}) is reverted")
else:
Expand Down
4 changes: 2 additions & 2 deletions broker/libs/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def upload(folder_to_share, tmp_dir, is_source_code=False):

is_file_exist = _list(tar_hash, is_folder=True)
if is_file_exist:
log(f"## requested folder {tar_hash} is already uploaded", "bold blue")
log(f"## requested folder {tar_hash} is already uploaded", "blue")
log(is_file_exist, "bg")
key = is_file_exist.partition("\n")[0].split()[0]
is_already_uploaded = True
Expand Down Expand Up @@ -288,7 +288,7 @@ def parse_gdrive_info(gdrive_info):

log(_dict)
except:
log(gdrive_info, "bold yellow")
log(gdrive_info, "yellow")


def size(key, mime_type, folder_name, gdrive_info, results_folder_prev, code_hashes, is_cached):
Expand Down
5 changes: 1 addition & 4 deletions broker/libs/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

from pymongo import MongoClient
from rich.pretty import pprint
from broker._utils import _log
from broker._utils._log import log

_log.IS_WRITE = False


class BaseMongoClass:
def __init__(self, mc, collection) -> None:
Expand Down Expand Up @@ -166,7 +163,7 @@ def main():
if args.is_delete_all:
ebb_mongo.delete_shared_ids()
output = ebb_mongo.delete_all()
log(f"mc['ebloc_broker']['cache'] is_deleted={output}")
log(f"mc['ebloc_broker']['cache'] is_deleted={output}", is_write=False)
else:
ebb_mongo.find_all_share_id()
# output = ebb_mongo.get_job_state_running_tx("QmRD841sowPfgz8u2bMBGA5bYAAMPXxUb4J95H7YjngU4K", 37)
Expand Down
14 changes: 7 additions & 7 deletions broker/test_setup/job_cppr.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
config:
requester_address: '0x740fcbc6d4e7e5102b8cba29370b93c6de4c786e'
provider_address: '0x4934a70ba8c1c3acfa72e809118bdd9048563a24'
requester_address: '0x4c2aebf67f8cfce387ad0ee3774bb193c4a62ef6'
provider_address: '0x1926b36af775e1312fdebcc46303ecae50d945af'
source_code:
storage_id: b2drop
storage_id: ipfs_gpg
cache_type: public
path: ~/test_eblocbroker/run_cppr
storage_hours: 0
data:
data1:
hash: f71df9d36cd519d80a3302114779741d
hash: 779745f315060d1bc0cd44b7266fb4da
data2:
hash: 1bfca57fe54bc46ba948023f754521d6
hash: 45281dfec4618e5d20570812dea38760
data3:
cache_type: public
path: /home/alper/test_eblocbroker/small/KZ2-sawtooth
path: /home/alper/test_eblocbroker/small/babyface.n6c10
storage_hours: 1
storage_id: b2drop
storage_id: ipfs_gpg
data_transfer_out: 5
jobs:
job1:
Expand Down
6 changes: 3 additions & 3 deletions broker/test_setup/job_nas.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
config:
requester_address: '0x2c73a80956516ba9e6005030faed2f8212bc10a3'
provider_address: '0x1926b36af775e1312fdebcc46303ecae50d945af'
requester_address: '0x72c1a89ff3606aa29686ba8d29e28dccff06430a'
provider_address: '0x4934a70ba8c1c3acfa72e809118bdd9048563a24'
source_code:
storage_id: ipfs_gpg
storage_id: b2drop
cache_type: public
path: ~/test_eblocbroker/NPB3.3-SER_source_code
storage_hours: 0
Expand Down
Loading

0 comments on commit 95f2e63

Please sign in to comment.