コード例 #1
0
ファイル: ppc_node.py プロジェクト: 7788251/Peerbox
    def __init__(self):
        self.username = ""
        self.password = ""
        self.testnet = False
        self.testnet_check()
        self.userpass()

        if self.testnet == False:
            self.node = Server('http://127.0.0.1:9902', 
                auth=(self.username, self.password))

        if self.testnet == True:
            self.node = Server('http://127.0.0.1:9904', 
                auth=(self.username, self.password))
コード例 #2
0
ファイル: ppc_node.py プロジェクト: 7788251/Peerbox
    def __init__(self):
        self.username = ""
        self.password = ""
        self.testnet = False
        self.testnet_check()
        self.userpass()

        if self.testnet == False:
            self.node = Server('http://127.0.0.1:9902',
                               auth=(self.username, self.password))

        if self.testnet == True:
            self.node = Server('http://127.0.0.1:9904',
                               auth=(self.username, self.password))
コード例 #3
0
ファイル: nu_node.py プロジェクト: peerchemist/NuBox
    def __init__(self, shares=True):
        self.username = ""
        self.password = ""
        self.shares = shares
        self.testnet = False
        self.testnet_check()
        self.userpass()

        if self.testnet == False:
            if shares == True:
                self.node = Server('http://127.0.0.1:14001', 
                    auth=(self.username, self.password))
            else:
                self.node = Server('http://127.0.0.1:14002',
                    auth=(self.username, self.password))

        if self.testnet == True:
            self.node = Server('http://127.0.0.1:15001', 
                auth=(self.username, self.password))
コード例 #4
0
    # pretrain_model_name = arguments['pretrain_model'][0]
    model_version = arguments['model_version']
    model_userid = arguments['model_userid']
    ams_id = arguments['ams_id']
    jsonrpcMlClientPoint = arguments['jsonrpcMlClientPoint']
    print('ip address is ', jsonrpcMlClientPoint)
    print('数据路径 :', img_src)

    # 数据集预处理
    X_train, X_valid, X_test, y_train, y_valid, y_test, num_classes, local_img_path = preprocessing_img(
        img_src, width, height, validata_percent, test_percent, HDFS_data=True)
    # 模型构建
    model = build_model(width, height, channel_num, num_classes,
                        user_optimizer)

    http_client = Server(jsonrpcMlClientPoint)
    # 训练可视化,返回val_acc, val_loss, train_acc, train_loss
    callbacks = TrainingMonitor(http_client=http_client,
                                model_id=modelId,
                                model_userid=model_userid,
                                model_version=model_version,
                                ams_id=ams_id)

    # checkpoint
    if not os.path.exists(save_dir):
        os.makedirs(save_dir)
    namepath = "trained_best_weights.h5"
    filepath = os.path.join(save_dir, namepath)
    print('current file path is : ', filepath)
    checkpoint = ModelCheckpoint(filepath,
                                 monitor='val_acc',
コード例 #5
0
ファイル: made_modelApp.py プロジェクト: lighTQ/ICTrain
    X_train, X_valid, X_test, y_train, y_valid, y_test, num_classes = preprocessing_img(
        img_src, width, height, validata_percent, test_percent)
    #    # 模型构建
    model = build_model(width, height, channel_num, num_classes,
                        user_optimizer)

    # print(model.summary())

    # 使用tensorfboard实时监控
    # tensorboard = TensorBoard(log_dir='./logs', histogram_freq=0,
    #                           write_graph=True, write_images=False)

    # history = model.fit(X_train, y_train, batch_size=batch_size, epochs=epochs,
    #                     shuffle=True, callbacks=[tensorboard])

    http_client = Server(jsonrpcMlClientPoint)

    # http_client = pyjsonrpc.HttpClient(
    #     url="http://192.168.10.141:8080/rpc/myservice"
    # )

    # 训练可视化,返回val_acc, val_loss, train_acc, train_loss
    cb = TrainingMonitor(http_client=http_client,
                         model_id=modelId,
                         model_userid=model_userid,
                         model_version=model_version,
                         ams_id=ams_id)

    # checkpoint
    if not os.path.exists(save_dir):
        os.makedirs(save_dir)
コード例 #6
0
ファイル: ppc_node.py プロジェクト: 7788251/Peerbox
class Node:
    
    def __init__(self):
        self.username = ""
        self.password = ""
        self.testnet = False
        self.testnet_check()
        self.userpass()

        if self.testnet == False:
            self.node = Server('http://127.0.0.1:9902', 
                auth=(self.username, self.password))

        if self.testnet == True:
            self.node = Server('http://127.0.0.1:9904', 
                auth=(self.username, self.password))

    def userpass(self):
        '''Reads .ppcoin/ppcoin.conf file for username/password'''

        with open('/home/{0}/.ppcoin/ppcoin.conf'.format(getpass.getuser()), 'r') as conf:
            for line in conf:
                if line.startswith('rpcuser'):
                    self.username = line.split("=")[1].strip()
                if line.startswith("rpcpassword"):
                    self.password = line.split("=")[1].strip()

    def testnet_check(self):
        with open('/home/{0}/.ppcoin/ppcoin.conf'.format(getpass.getuser()), 'r') as conf:
            for line in conf:
                if line.startswith("testnet"):
                    if (line.split("=")[1] == 1 or line.split("=")[1] == True):
                        #self.testnet = True
                        return True

    def walletpassphrase(self, passphrase, timeout=999999, mint_only=True):
        '''used to unlock wallet for minting'''
        return self.node.walletpassphrase(passphrase, timeout, mint_only)

    def getblock(self, blockhash):
        '''returns detail block info.'''
        return self.node.getblock(blockhash)

    def getblockcount(self):
        '''Retrieve last block index'''
        return self.node.getblockcount()

    def getblockhash(self, block):
        '''retrieve block hash'''
        return self.node.getblockhash(block)

    def getbalance(self):
        '''retrieve balance'''
        return self.node.getbalance()

    def getdifficulty(self):
        '''Get PoS/PoW difficulty'''
        return self.node.getdifficulty()

    def getpeerinfo(self):
        '''Get connected peer's info'''
        return self.node.getpeerinfo()

    def getinfo(self):
        return self.node.getinfo()

    def getaddressesbyaccount(self, account=""):
        '''can be used to list asociated addresses'''
        return self.node.getaddressesbyaccount(account)

    def createnewaddress(self):
        return self.node.createnewaddress()

    def sendtoaddress(self, recv_addr, amount, comment=""):
        '''send ammount to address, with optional comment. Returns txid.
        sendtoaddress(ADDRESS, AMMOUNT, COMMENT)'''
        return self.node.sendtoaddress(recv_addr, amount, comment)

    def getconnectioncount(self):
        '''Get number of active connections'''
        return self.node.get_conn_count()

    def getdifficulty(self):
        '''Get PoS/PoW difficulty'''
        return self.node.getdifficulty()

    def getrawtransaction(self, txid, verbose=1):
        '''get raw transaction'''
        return self.node.getrawtransaction(txid, verbose)

    def getrawmempool(self):
        '''returns raw mempool'''
        return self.node.getrawmempool()

    def listtransactions(self):
        '''list all transactions associated with this wallet'''
        return self.node.listtransactions()

    def listreceivedbyaddress(self, minconf=0, includeempty=True):
        '''get list of all accounts in the wallet'''
        return self.node.listreceivedbyaddress(minconf, includeempty)

    def listunspent(self):
        '''list only unspent UTXO's'''
        return self.node.listunspent()
コード例 #7
0
ファイル: ppc_node.py プロジェクト: 7788251/Peerbox
class Node:
    def __init__(self):
        self.username = ""
        self.password = ""
        self.testnet = False
        self.testnet_check()
        self.userpass()

        if self.testnet == False:
            self.node = Server('http://127.0.0.1:9902',
                               auth=(self.username, self.password))

        if self.testnet == True:
            self.node = Server('http://127.0.0.1:9904',
                               auth=(self.username, self.password))

    def userpass(self):
        '''Reads .ppcoin/ppcoin.conf file for username/password'''

        with open('/home/{0}/.ppcoin/ppcoin.conf'.format(getpass.getuser()),
                  'r') as conf:
            for line in conf:
                if line.startswith('rpcuser'):
                    self.username = line.split("=")[1].strip()
                if line.startswith("rpcpassword"):
                    self.password = line.split("=")[1].strip()

    def testnet_check(self):
        with open('/home/{0}/.ppcoin/ppcoin.conf'.format(getpass.getuser()),
                  'r') as conf:
            for line in conf:
                if line.startswith("testnet"):
                    if (line.split("=")[1] == 1 or line.split("=")[1] == True):
                        #self.testnet = True
                        return True

    def walletpassphrase(self, passphrase, timeout=999999, mint_only=True):
        '''used to unlock wallet for minting'''
        return self.node.walletpassphrase(passphrase, timeout, mint_only)

    def getblock(self, blockhash):
        '''returns detail block info.'''
        return self.node.getblock(blockhash)

    def getblockcount(self):
        '''Retrieve last block index'''
        return self.node.getblockcount()

    def getblockhash(self, block):
        '''retrieve block hash'''
        return self.node.getblockhash(block)

    def getbalance(self):
        '''retrieve balance'''
        return self.node.getbalance()

    def getdifficulty(self):
        '''Get PoS/PoW difficulty'''
        return self.node.getdifficulty()

    def getpeerinfo(self):
        '''Get connected peer's info'''
        return self.node.getpeerinfo()

    def getinfo(self):
        return self.node.getinfo()

    def getaddressesbyaccount(self, account=""):
        '''can be used to list asociated addresses'''
        return self.node.getaddressesbyaccount(account)

    def createnewaddress(self):
        return self.node.createnewaddress()

    def sendtoaddress(self, recv_addr, amount, comment=""):
        '''send ammount to address, with optional comment. Returns txid.
        sendtoaddress(ADDRESS, AMMOUNT, COMMENT)'''
        return self.node.sendtoaddress(recv_addr, amount, comment)

    def getconnectioncount(self):
        '''Get number of active connections'''
        return self.node.get_conn_count()

    def getdifficulty(self):
        '''Get PoS/PoW difficulty'''
        return self.node.getdifficulty()

    def getrawtransaction(self, txid, verbose=1):
        '''get raw transaction'''
        return self.node.getrawtransaction(txid, verbose)

    def getrawmempool(self):
        '''returns raw mempool'''
        return self.node.getrawmempool()

    def listtransactions(self):
        '''list all transactions associated with this wallet'''
        return self.node.listtransactions()

    def listreceivedbyaddress(self, minconf=0, includeempty=True):
        '''get list of all accounts in the wallet'''
        return self.node.listreceivedbyaddress(minconf, includeempty)

    def listunspent(self):
        '''list only unspent UTXO's'''
        return self.node.listunspent()