Beispiel #1
0
def create_rpc_component(remote=True):
    return RPCComponent(
        cli_secret_filepath='{datadir}/crossbar/secrets/golemcli.tck'.format(
            datadir=datadir),
        rpc_cert_filepath='{datadir}/crossbar/rpc_cert.pem'.format(
            datadir=datadir),
        remote=remote)
    # 1. Returning a serializable object that will be written
    # to result.json in form:
    # {
    #   'result': serialized_object
    # }
    if args and 'prefix' in args:
        return args['prefix'] + content
    else:
        return 'default prefix ' + content
    # 2. Writing files to '/golem/output' directory.


# Create an RPC component connected to our AWS hosted Golem. 
rpc = RPCComponent(
    host='35.158.100.160',
    cli_secret_filepath='golemcli_aws.tck',
    rpc_cert_filepath='rpc_cert_aws.pem'
)

# Here a separate thread for RPC is created.
# Now user can send messages to the RPC Component to interact with
# remote Golem node.
rpc.start()

rpc.post({
    'type': 'CreateTask',
    'task': {
        'type': 'GLambda',
        'options': {
            'method': my_task,
            'args': {'prefix': 'myprefix_string '},
Beispiel #3
0
# For presentation purpose pick only arandom pair of files
filtered_files = cif_files[18:20]

# Load them into memory
files_content_arr = [
    open(f, 'r').read() for f in filtered_files
]

# Golem default installation directory is where we obtain cli_secret_filepath and rpc_cert_filepath
# required for establishing connection with remote Golem.
datadir = '{home}/.local/share/golem/default/rinkeby'.format(home=Path.home())

# cli_secret_filepath and rpc_cert_filepath paths specified below are default for typical Golem installation.
rpc = RPCComponent(
    cli_secret_filepath='{datadir}/crossbar/secrets/golemcli.tck'.format(
        datadir=datadir),
    rpc_cert_filepath='{datadir}/crossbar/rpc_cert.pem'.format(datadir=datadir)
)

rpc.start()

tasks = [
    {
        'type': 'GLambda',
        'options': {
            'method': raspa_task,
            'args': {'mol': mol}
        },
        'timeout': '00:10:00'
    }
    for mol in files_content_arr

def user_task(args):
    '''Dummy task to compute provider side
    '''
    return EXPECTED_TASK_RESULT


# Golem default installation directory is where we obtain cli_secret_filepath and rpc_cert_filepath
# required for establishing connection with remote Golem.
datadir = '{home}/.local/share/golem/default/rinkeby'.format(home=Path.home())

# cli_secret_filepath and rpc_cert_filepath paths specified below are default for typical Golem installation.
rpc = RPCComponent(
    cli_secret_filepath='{datadir}/crossbar/secrets/golemcli.tck'.format(
        datadir=datadir),
    rpc_cert_filepath='{datadir}/crossbar/rpc_cert.pem'.format(
        datadir=datadir))

rpc.start()

# 1. User creates a task with verification of type EXTERNALLY_VERFIED
# 2. User acquires `task_id` from TaskCreatedEvent to later track
# the results of his task
# 3. User verifies the results and responds with 'VerifyResults' message
# with appropriate `verdict` set.
# 4. User receives `TaskResults` message

response = rpc.post_wait({
    'type': 'CreateTask',
    'task': {
Beispiel #5
0
    # }
    if args and 'prefix' in args:
        return args['prefix'] + content
    else:
        return 'default prefix ' + content
    # 2. Writing files to '/golem/output' directory.


# Golem default installation directory is where we obtain cli_secret_filepath and rpc_cert_filepath
# required for establishing connection with remote Golem.
datadir = '{home}/.local/share/golem/default/rinkeby'.format(home=Path.home())

# cli_secret_filepath and rpc_cert_filepath paths specified below are default for typical Golem installation.
rpc = RPCComponent(
    cli_secret_filepath='{datadir}/crossbar/secrets/golemcli.tck'.format(
        datadir=datadir),
    rpc_cert_filepath='{datadir}/crossbar/rpc_cert.pem'.format(
        datadir=datadir))

# Here a separate thread for RPC is created.
# Now user can send messages to the RPC Component to interact with
# remote Golem node.
rpc.start()

rpc.post({
    'type': 'CreateTask',
    'task': {
        'type': 'GLambda',
        'options': {
            'method': my_task,
            'args': {
        "output_path": Path.home().as_posix(),
        "format": "PNG",
        "resolution": [400, 300]
    }
}

# Golem default installation directory is where we obtain cli_secret_filepath and rpc_cert_filepath
datadir = '{home}/.local/share/golem/default/rinkeby'.format(home=Path.home())

# Authenticate with localhost:61000 (default) golem node using cli_secret_filepath
# and rpc_cert_filepath specified
rpc = RPCComponent(
    cli_secret_filepath='{datadir}/crossbar/secrets/golemcli.tck'.format(
        datadir=datadir),
    rpc_cert_filepath='{datadir}/crossbar/rpc_cert.pem'.format(
        datadir=datadir),
    # Inform RPCComponent that Golem node is local to the application.
    # Resources will not be unnecessarily uploaded.
    # Field `resources_mapped` in `CreateTask` message will be ignored
    remote=False)

# Here a separate thread for RPC is created.
# Now user can send messages to this the RPC Component to interact with
# remote Golem node.
rpc.start()

# Ignore TaskCreatedEvent
_ = rpc.post_wait({'type': 'CreateTask', 'task': blender_dict})

response = rpc.poll(timeout=None)
print(response['results'])
Beispiel #7
0
# List all files from ./raspa_data
cif_files = [
    filepath.absolute() for filepath in Path('./raspa_data').glob('*.cif')
]

assert cif_files, 'please run this example from a directory where raspa_data/ exist (examples?)'

# For presentation purpose pick only arandom pair of files
filtered_files = cif_files[18:20]

# Load them into memory
files_content_arr = [open(f, 'r').read() for f in filtered_files]

# Create an RPC component connected to our AWS hosted Golem.
rpc = RPCComponent(host='35.158.100.160',
                   cli_secret_filepath='golemcli_aws.tck',
                   rpc_cert_filepath='rpc_cert_aws.pem')

# Here a separate thread for RPC is created.
# Now user can send messages to this the RPC Component to interact with
# remote Golem node.
rpc.start()

tasks = [{
    'type': 'GLambda',
    'options': {
        'method': raspa_task,
        'args': {
            'mol': mol
        }
    },