Giter VIP home page Giter VIP logo

Comments (8)

thclark avatar thclark commented on June 23, 2024 1

And/Or some similar useful APIs, yes, that'd be elegant. contains might be a good one too.

Perhaps this is a good opportunity to implement a chainable filter on TagGroup which could work like a list except with extra methods to filter further - so you could go, for example:

<thing>.getTags.startswith('meta').contains('sys2').subTags()[-1]

which, if applied to a Taggable with tags="tag1 tag2 meta:sys1:1234 meta:sys2:3456" would result in 3456.

from octue-sdk-python.

thclark avatar thclark commented on June 23, 2024 1

@thclark I've implemented chained filtering 💯 Isn't the proposed has method the same as __contains__?

It certainly can be, but I don't know whether we want to use __contains__ for that. Probably don't want to overload such an important method in a mixin.

For example, a Dataset is a Taggable but you'd want to reserve __contains__ for much more obvious uses like if <DataFile> in Dataset.

from octue-sdk-python.

thclark avatar thclark commented on June 23, 2024

@time-trader you might want to follow this

from octue-sdk-python.

cortadocodes avatar cortadocodes commented on June 23, 2024

@thclark do you want the startswith etc methods to be able to work on subtags too? Or just be able to get subtags from a TagGroup?

from octue-sdk-python.

thclark avatar thclark commented on June 23, 2024

The other side of the problem is needing to be able to test against tags, for searching matching files in a manifest.

This is where we really should be using a search index and lucene syntax, which we could do trivially if this were online-only. But there aren't any native python implementations (everything requires a JVM, and I foresee trouble ahead with that...), and being able to do it locally would be helpful.

But, we could implement a has method on the taggable class that returns T/F given the filters above.

That'd allow us to implement a match_files() method on a a Dataset which would implement a crude O(MN) search (M = no. tags, N = no. files) for files meeting those criteria.

from octue-sdk-python.

cortadocodes avatar cortadocodes commented on June 23, 2024

@thclark I've implemented chained filtering 💯 Isn't the proposed has method the same as __contains__?

from octue-sdk-python.

thclark avatar thclark commented on June 23, 2024

Maybe we use something more descriptive though, like has_tag or has_tags

from octue-sdk-python.

cortadocodes avatar cortadocodes commented on June 23, 2024

I've swapped __contains__ for has_tag but I've just realised that it doesn't matter if we have loads of magic methods for TagGroup as it's not a mixin - its instances are used as an attribute of a mixin.

from octue-sdk-python.

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.