Coder Social home page Coder Social logo

Parallel processing about navis HOT 4 CLOSED

navis-org avatar navis-org commented on June 11, 2024
Parallel processing

from navis.

Comments (4)

clbarnes avatar clbarnes commented on June 11, 2024

Pathos looks good to me! Agree that it could be an optional extra - the boilerplate for throwing the error when the function is called instead of on import would only need to be written in the decorator definition.

I'm aware of dill but am not very familiar with it - with any luck it allows out-of-band data like pickle 5 does. That significantly speeds up the ser/deser of numpy arrays. The default pickle has been 4 since python 3.8, so I suspect that's what the multiprocessing queues use 👎 .

An alternative way of dispatching operations over neuronlists would be something like this, implementing the parallelisation on the neuronlist:

def prune_neuron(neuron, param, more_params=None):
    ...
    return changed_neuron


class NeuronList:
    ...
    def map(self, fn, *args, parallel=None, **kwargs):
        if parallel:
            ...
        else:
            neurons = [fn(n, *args, **kwargs) for n in self]
        return type(self)(neurons)

You could still have a decorator as you suggest, it could just delegate its parallelism to NeuronList.map. I don't have strong feelings about which one to prefer!

In general I think it's a great step to factor out the dataframe/treeneuron/neuronlist into some shared implementation; same for handling parallelism setup (e.g. None for serial, 0 for max(1, (os.cpu_count() or 0) - 1)), although that might be a bit more tricky as sometimes you want more spare CPUs, or you prefer to use threading or whatever.

from navis.

schlegelp avatar schlegelp commented on June 11, 2024

Actually your other suggestion already exists in NeuronList.apply :)

I was thinking of keeping that because it generalizes to any function - including non-navis functions. The advantage of the decorator is that we know that the output will be a NeuronList which makes some things easier.

from navis.

clbarnes avatar clbarnes commented on June 11, 2024

Aha! My Ctrl+f was insufficient. Yes, that makes sense!

from navis.

schlegelp avatar schlegelp commented on June 11, 2024

Implemented with 1c8ffe6

from navis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.