-
Notifications
You must be signed in to change notification settings - Fork 23
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
Create PURL services CLI tool and library #247
Comments
@pombredanne @AyanSinhaMahapatra I've looked at the SCTK fetch_thirdparty.py example, but I have to admit that I don't understand what a complete command for that utility would look like or how it might apply to the current issue. Examples of how to run the In addition, the description above of the current issue seems rather vague. What does it mean to create a client API tool to access PURL services? Examples of PURL services we want to handle, and some descriptions of user input and output, would be particularly helpful. The only exposure I've had so far with the PurlDB is the experimentation I've done since last Friday evening with the new
|
@pombredanne Now that we've (initially) addressed the |
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
@pombredanne As noted last week, I'm blocked for now from additional CLI work until we can add the missing details to your initial description of this issue, i.e., ID the additional services, commands and use cases we want to include. |
So the next steps after validate (and after adding tests to validate) would be to use the latest and new fetchcode as a library to add two new sub commands:
After this I would like to see these:
|
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
@pombredanne Re the first bullet above -- a
|
Compare just the versions as strings, e.g.,
|
@pombredanne Do we want to get version data for both one PURL and for multiple PURLs, depending on the user's need? (Just as we do with validating either a single PURL or a list of PURLs.) Also: What should the output look like: a list of string versions, or JSON (and if so, what would it look like)? |
Always start with a single PURL. Expanding to a list is easy. The output could be either:
This will account for multiple PURLs in both cases. Eventually the output will need account for the input in some header instead, much like in a ScanCode scan, but this is for the future, but nothing urgent for now. |
Manage objects internally, and deal with simple/plain serialized Python data at the end only. |
Thanks @pombredanne . 👍 |
I'm working on the
My CLI code detects the empty list and displays a message in the terminal ( Is there some way to do this? |
More info: The fetchcode error is displayed in the terminal each time one of these two variables is defined in the code (they produce an empty list):
These, otoh, do not invoke a fetchcode error displayed in the terminal, and each produces a generator object.
|
Actually, I should be able to use 'validate' and display a message to the user for each PURL for which 'validate' returns |
@johnmhoran I would not worry too much about the CLI output for now, as long as the JSON is correct |
@pombredanne so shall we remove https://github.com/nexB/fetchcode/blob/d0a3fa9bb56dc3a77f7d3d7bd5b8d0e40c7a8612/src/fetchcode/package_versions.py#L523 the logger and raise errors instead? |
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Reference: #247 Signed-off-by: John M. Horan [email protected]
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
@pombredanne @JonoYang I'm close to being ready to commit and push my latest I ran
No idea why, no reason to think this results from my work, but who knows? Unless you suggest otherwise, I'm going to vet my code and tests for a final cleanup, commit and push. ;-) |
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Just committed and pushed. |
@johnmhoran I wouldn't mind the |
Great -- thank you @JonoYang . 👍 |
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Reference: #247 Signed-off-by: John M. Horan [email protected]
@JonoYang I see that the PR I just merged has a failed test due to the fact that many of the commands I'm adding include dynamic values -- URLs and versions -- and they change and in this case the This sort of issue will arise going forward for many of these URLs, and for |
In You can also look into mocking API responses for certain tests to return a set of expected data that you define. An example of a test using mock is https://github.com/nexB/purldb/blob/1272a61ce885d600ee79969de05d0e1c34b283e4/packagedb/tests/test_package_managers.py#L72 |
Thank you @JonoYang -- I'll give these a close look. The |
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
…d code and tests #247 Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Reference: #247 Signed-off-by: John M. Horan <[email protected]>
@JonoYang @pombredanne One error I have been unable to catch or otherwise prevent is the error and traceback (interrupting the purlcli command's flow) thrown by fetchcode's
I think the fix will be needed in fetchcode/package.py itself -- perhaps in the first of these 2 package_versions.py functions (below) involved in the error/traceback, adding something like the following might simply return (Meanwhile I will invest no more time on this intermittent error and return to my refactoring/cleaning with the goal of converting my current draft PR #305 to review status ASAP -- that will represent the first 4 commands (
See |
That makes sense to me. @keshav-space What do you think is the best way to handle a 503 error when getting debian packages? The exception in question is in #247 (comment) |
@JonoYang @johnmhoran >>> from fetchcode.package_versions import versions
>>> r=versions("pkg:deb/debian/2ping")
>>> list(r)
[PackageVersion(value='4.5-1.2', release_date=None), PackageVersion(value='4.5-1.1', release_date=None), PackageVersion(value='4.5-1', release_date=None), PackageVersion(value='4.3-1', release_date=None), PackageVersion(value='3.2.1-1+deb9u1', release_date=None), PackageVersion(value='2.1.1-1', release_date=None), PackageVersion(value='2.0-1', release_date=None)] Nevertheless, we should be bit more skeptical while processing the upstream data. In the event that we're unable to get proper metadata or version information, we should simply return an empty list. @johnmhoran , please enter an issue for this in fetchcode. |
@keshav-space @JonoYang Am I correct in thinking that for now there is nothing I can do on my purlcli end to handle this? |
…247 Reference: #247 Signed-off-by: John M. Horan <[email protected]>
@JonoYang @pombredanne Earlier today I pushed an update to my open PR #305 that includes substantial updates to the first four commands --
Please let me know what priority I should assign to these two new commands and the |
@johnmhoran You can catch these exceptions in |
@keshav-space Can you explain how I can catch them in |
@johnmhoran IMO this doesn't need immediate handling, and we should not try to handle this from |
Ok sounds good -- thanks @keshav-space |
Reference: #305 Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Reference: #305 Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Reference: #305 Reference: #247 Signed-off-by: John M. Horan <[email protected]>
Current status summary:
|
This is now completed. The main tool has been released at https://pypi.org/project/purldb-toolkit/ which is a new sub project and package for this: This purlcli acts as a client to the REST API end point(s) to expose the new PURL services. It serves both as a tool and as an example on how to use the services programmatically.
We also added support for:
To back this feature, we also created a new PURLDB API endpoint that can validate a PURL. It takes a
We now have these sub commands implemented and tested that are clients to the REST API endpoint(s) and also reuse the other libraries (packageurl and fetchcode) extensively:
To test this feature:
See also https://github.com/nexB/purldb/blob/main/purldb-toolkit/README.rst for command line utility help |
To best support using various PURL-based services, I would like to have a command client tool and library as a client API that can expose these services for integration elsewhere.
The text was updated successfully, but these errors were encountered: