-
Notifications
You must be signed in to change notification settings - Fork 12
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
I2C library discovery tool #25
Comments
I like this idea! I am thinking I should be a different function primarily for clarity and if we want to add more advanced querying to the function we are not slamming that into the same function that provides a list of i2c devices that are on the bus. I can work on this later this week, as I need to get the first pass of the website in a PR first. |
So I have a basic prototype CLI tool that can search hex by dependency and print out the packages that use that dependency. However, I saw a conversation involving searching by I personally like having the CLI tool, but I can also see a more general hex api library that can be shared in different projects. |
@mattludwigs I think your hex-search CLI tool is a fantastic idea. I can finish that tool for you if you are no longer interested in pursuing it. Right now the list of "What uses Elixir Circuits?" on the website is where most developers will go to search for device libraries. |
Thanks! I stopped working on as we never decided if it should live in the circuits code so that one would have to get the dep and use iex to run a function to list this out, or if it should live outside the elixir code so that a user can search hex from their terminal. Or even something else. I wrote mine to work more generically outside of the context of elixir circuits and to work as a CLI tool. Which also means it's in a different language than Elixir, which is less shareable to other Elixir projects. I know personally, I would use a tool like that. If that is desirable I am not sure if that would live in elixir circuits though. Maybe it can be be made into a mix archive, so the tool can be installed and ran as a mix task? Maybe the answer is both? Also, if there is a way to make the packages more searchable on the webpage I am open to thoughts on that. @fhunleth I would like to get your thoughts about this. |
This seems really useful. Is there anything to look at? If the question is whether to integrate the tool in Circuits.I2C, then I think that decision is made after there's some experience using and maintaining it. When the tool is available, I think we'll definitely want to put a link to it here to help people find it. |
I guess my question is: Should it be Elixir based CLI via mix task or another language? Is CLI a good solution? I have some really rough prototype code I can share but its more generalized then circuits.... and it's not in Elixir. 🦀 |
A general purpose CLI tool that could search for hex packages by dependency would benefit the entire Elixir community. I think it should be a mix task since anyone looking for hex packages is probably using mix and thereby already has it installed. CLI is a great solution. I would definitely reach for a CLI tool before I start cobbling together raw queries against the hex API. I looked at the mix documentation and there is nothing like a |
I think that is a really good point. From conversations, I think that there are few things to do that would both accomplish shared code, plus the specific goals for circuits (and other libraries).
For those points, I don't think circuits should own those repos, but it can use the first one. Also, shared code and the CLI tooling are both made available.
Interested to hear other thoughts on this. I think the goals are realistic and meet the desired goals discussed throughout this thread. |
I started working on task number 1 yesterday. You can find the repo for my Hex API client here. I plan to use HTTPoison to query Hex.pm. I'll let you know when I have it working so Circuits can link to it. |
I went through the Hex API spec on Apiary and it turns out that "dependents" is not an attribute of the "package" JSON schema. Even retrieving the list of "dependencies" for a package is a bit roundabout using the Hex API. The "package" response includes a list of "releases" rather than dependencies. You then need to issue another request to the Hex API for a "release" by package "name" and release "version" to get the list of "dependencies" for a particular package release. From what I can tell, the Hex.pm website relies on an Ecto query to a database to fill in the "Dependents(n):" section that appears on each package web page. Excerpt from hexpm/lib/hexpm_web/controllers/package_controller.ex
Excerpt from hexpm/lib/hexpm/repository/package.ex
Based on the above, I don't think the Hex.pm website fetches "depends" from the Hex API server which is unfortunate. @mattludwigs I am now very curious now how your prototype |
I haven't looked too closely at their documentation and it's been a long time so I don't remember what lead me to using this endpoint:
Which in my prototype CLI I interpolate the url like so (it's not in Elixir): let url = format!("https://hex.pm/api/packages?search=depends%3A{}", dep); Where |
Thank you @mattludwigs! That API search request works beautifully. |
So my body
|> Jason.decode!
|> Enum.filter(fn(package) ->
if search_string = context[:containing] do
description = package["meta"]["description"]
String.contains?(description, search_string)
else
true
end
end)
|> Enum.map(fn(package) -> IO.puts package["name"] end) If there were I2C device addresses included somewhere in the Hex package descriptions a Let me know if you have any feature requests. I'd like to extend this project into a more general purpose Hex API client and add more useful functionality like search for packages by owner. Let's see if there is any interest first. |
Over the past few years, I've learned that new users have a hard time finding device libraries so they sometimes re-implement support for a device (or give up). Good libraries also go unused due to naming being difficult (not I2C, but how do you name a library for WS2812 LEDs so everyone finds it? Name it neopixel? or what if dotstar support is added, then is it called "leds". Or just name it the LED part number).
It seems like
Circuits.I2C.detect_devices/1
(or a new function) could help. Hex.pm has an API to query for packages. The query might be all libraries that depend oncircuits_i2c
and have an I2C address in their metadata. We'd have to publicize and work with library authors to add appropriate metadata to their packages.The text was updated successfully, but these errors were encountered: