Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for getting artifacts #40

Merged
merged 2 commits into from
Aug 8, 2016
Merged

Add support for getting artifacts #40

merged 2 commits into from
Aug 8, 2016

Conversation

msabramo
Copy link
Contributor

@msabramo msabramo commented Aug 5, 2016

The idea here is to have an Artifact class with an API that loosely resembles the API of Path objects in path.py, wherever it makes sense to.

Cc: @aconrad

@msabramo msabramo changed the title Add support for getting artifacts WIP: Add support for getting artifacts Aug 5, 2016
return self.splitext()[1]

def fnmatch(self, pattern):
return fnmatch.fnmatch(self.name, pattern)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to be used when you are going through a collection of artifacts to see which one matches a glob pattern?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If yes, what would be the scenario? (pseudo code)

Copy link
Contributor

@aconrad aconrad Aug 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm basically wondering if we could have something like an ArtifactFinder class that would hide this detail and do:

af = ArtifactFinder(...)
artifacts = af.find("*.xml")  # returns collection of artifacts

... so you don't have to expose Artifact.fnmatch(), the artifact finder could just run fnmatch(Artifact.name, "*.xml").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a use case in mind for Artifact.fnmatch(). I implemented it to have parity with path.py.

The ArtifactFinder is a good idea, though I think there are some methods here that do that (again, I borrowed them from path.py). Look at the dirs, files, and listdir methods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My recommendation is to not eagerly implement methods that you expose as a public API. If you haven't put much thought into and and you make it public, well then you are stuck with it. Every time I implement code I ask myself 2 things:

  1. do I have a use case for it?
  2. if yes and it's a public API, is it really mature enough to be implemented knowing that if I need to change the signature later then I won't be able to make backwards incompatible changes easily.

You'd have to write tests for it too, which is additional work. But granted, this is not necessarily the riskiest API but still worth considering.

@msabramo msabramo merged commit 1931df0 into future Aug 8, 2016
@msabramo msabramo deleted the artifacts branch August 8, 2016 14:52
msabramo added a commit that referenced this pull request Aug 8, 2016
@msabramo msabramo changed the title WIP: Add support for getting artifacts Add support for getting artifacts Aug 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants