Beispiel #1
0
from sys import argv

from lab_3.task1_utils import multiply_arrs
from utils.mpi_helper import init, finalize

# noinspection PyShadowingNames
from utils.utils import current_time_millis, find_numpy_array_human_size, enum, track_time

array_size = int(argv[1])

init()

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
tags = enum('ARRAY_0', 'ARRAY_1', 'COMPUTATION_RESULT')

if rank == 0:
    a = np.random.rand(array_size)
    b = np.random.rand(array_size)

    print "a:", find_numpy_array_human_size(a)
    print "b:", find_numpy_array_human_size(b)

    track_time("1 process work time", lambda: multiply_arrs(a, b))

    mp_s_time = current_time_millis()
    offset = int(array_size / size)
    self_a_i = np.empty(1)
    self_b_i = np.empty(1)
Beispiel #2
0
        pass

    @abstractmethod
    def find_one_by(self, model, column_name, column_value):
        pass

    @abstractmethod
    def upsert(self, model):
        pass

    @abstractmethod
    def delete(self, model):
        pass


JoinType = enum('INNER', 'LEFT')


class InMemory(DB):
    """ Class implementing an in memory database with CRUD operations """

    # dictionary containing all the model data (with Base.model_name as keys)
    store = dict()

    def find_all(self, model):
        """ Find all objects of model type in the store
        @return list of model"""
        model_name = get_model_name(model)
        return self.store.get(model_name)

    def find_one_by(self, model, column_name, column_value):
Beispiel #3
0
class FT: # father_tuple in state.fathers
    tags = enum('F','S','E_PHRASE','PARTIAL_SCORE','FATHER_KEY')
Beispiel #4
0
from mpi4py import MPI

import numpy as np

from sys import argv

from lab_3.task2_utils import max_el
from utils.mpi_helper import init, finalize

# noinspection PyShadowingNames
from utils.utils import current_time_millis, find_numpy_array_human_size, enum, track_time

array_size = int(argv[1])
tags = enum('ARRAY', 'COMPUTATION_RESULT')

init()

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()

if rank == 0:
    arr = np.random.rand(array_size)

    print "arr:", find_numpy_array_human_size(arr)
    track_time("1 process work time", lambda: max_el(arr))

    mp_s_time = current_time_millis()
    offset = int(array_size / size)
    self_arr = np.empty(1)
Beispiel #5
0

class ForbiddenActionException(Exception):
    def __init__(self, msg):
        self.msg = msg


class UserNotLoggedException(Exception):
    def __init__(self, msg):
        self.msg = msg


PermissionType = enum(
    'READ_DISCUSSION',
    'ADD_POST',
    'ADD_IDEA',
    'REMOVE_POST',
    'REMOVE_IDEA'
)


def permissions_check(permission):
    """ Decorator to check user permissions on some actions """

    def decorated(func):

        def wrapper(*args, **kwargs):
            user_session = UserSession()
            if not user_session.current_user:
                raise UserNotLoggedException('User should be connected')
            if permission and permission in UserSession.current_user.permissions:
Beispiel #6
0
                raise ModelRestrictionError('Value type not allowed for ' +
                                            column_name)

    @abstractproperty
    def columns(self):
        """ Columns list defining the model """
        return []

    def persist(self):
        return self.db.upsert(self)

    def delete(self):
        return self.db.delete(self)


ColumnType = enum('STRING', 'DATETIME', 'NUMERIC')


class Column:
    """ The Attribute class is used to register the model attributes
        The definition includes column name and the type of data
     """
    def __init__(self,
                 column_name,
                 column_type,
                 primary_key=False,
                 foreign_key=False):
        self.column_name = column_name
        self.column_type = column_type
        self.primary_key = primary_key
        # FIXME: foreign_key is not used for now