# Path: perses/dispersed/parallel.py
# class Parallelism(object):
#     def activate_client(self,
#                         library = ('dask', 'LSF'),
#                         num_processes = 2,
#                         timeout = 1800):
#     def deactivate_client(self):
#     def scatter(self, df, workers = None):
#     def deploy(self, func, arguments, workers = None):
#     def run_all(self, func, arguments, workers):
#     def gather_results(self, futures, omit_errors = False):
#     def gather_actor_result(self, future):
#     def launch_actor(self, _class):
#     def progress(self, futures):
#     def wait(self, futures):


import numpy as np
import os
from nose.tools import nottest
from unittest import skipIf
from perses.dispersed import parallel
running_on_github_actions = os.environ.get('GITHUB_ACTIONS', None) == 'true'



def test_Parallelism_local():
    """
    following function will create a local Parallelism instance and run all of the used methods.
    """
    _parallel = parallel.Parallelism()

    #test client activation
    _parallel.activate_client(library = None, num_processes = None)
    assert hasattr(_parallel, 'library')
    assert _parallel.client == None
    assert _parallel._adapt == False
    assert _parallel.num_processes == 0
    assert _parallel.workers == {}

    data = np.arange(10)

    run_parallelism(_parallel, data)


# Run this test on a cluster to test parallelism
@skipIf(running_on_github_actions, "Skip helper function on GH Actions")
def test_Parallelism_distributed():
   """
   following function will create a distributed Parallelism instance and run all of the used methods.
   Note : this can only be run on a nosetest since GH Actions cannot access dask_jobqueue or any python distributed libraries.
   """

# Path: perses/dispersed/parallel.py
# class Parallelism(object):
#     def activate_client(self,
#                         library = ('dask', 'LSF'),
#                         num_processes = 2,
#                         timeout = 1800):
#     def deactivate_client(self):
#     def scatter(self, df, workers = None):
#     def deploy(self, func, arguments, workers = None):
#     def run_all(self, func, arguments, workers):
#     def gather_results(self, futures, omit_errors = False):
#     def gather_actor_result(self, future):
#     def launch_actor(self, _class):
#     def progress(self, futures):
#     def wait(self, futures):


# Path: perses/tests/test_parallel.py
import numpy as np
import os
from nose.tools import nottest
from unittest import skipIf
from perses.dispersed import parallel

running_on_github_actions = os.environ.get('GITHUB_ACTIONS', None) == 'true'



def test_Parallelism_local():
    """
    following function will create a local Parallelism instance and run all of the used methods.
    """
    _parallel = parallel.Parallelism()

    #test client activation
    _parallel.activate_client(library = None, num_processes = None)
    assert hasattr(_parallel, 'library')
    assert _parallel.client == None
    assert _parallel._adapt == False
    assert _parallel.num_processes == 0
    assert _parallel.workers == {}

    data = np.arange(10)

    run_parallelism(_parallel, data)


# Run this test on a cluster to test parallelism
@skipIf(running_on_github_actions, "Skip helper function on GH Actions")
def test_Parallelism_distributed():
   """
   following function will create a distributed Parallelism instance and run all of the used methods.
   Note : this can only be run on a nosetest since GH Actions cannot access dask_jobqueue or any python distributed libraries.
   """

   _parallel = parallel.Parallelism()