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
hydron: init at 2018-07-11 #43308
hydron: init at 2018-07-11 #43308
Conversation
78a4467
to
045fd55
Compare
Don't merge yet, depends on #43362 |
Ready for merging again. Having a service makes this package much more useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These options seem a bit arbitrary, do a lot of users of hydron regularly add/remove certain tags and remove ids?
It might be better to just provide a single option that allows the user to easily execute other commands before start. Although that can be done by using systemd.services.hydron.script = mkBefore "some command";
already iirc.
pkgs/servers/hydron/default.nix
Outdated
|
||
src = fetchgit { | ||
inherit rev; | ||
url = "https://github.com/bakape/hydron"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use fetchFromGitHub
instead
|
||
serviceConfig = { | ||
PermissionsStartOnly = true; | ||
Type = "simple"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"simple"
is the default, can be removed
options.services.hydron = { | ||
enable = mkEnableOption "hydron"; | ||
|
||
baseDir = mkOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more common to use dataDir
listenAddress = mkOption { | ||
type = types.nullOr types.str; | ||
default = null; | ||
description = "Listen on a specific IP address and port."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an explanation of which format this is expected to be in? <ip>:<port>
I assume?
I would like to keep the granularity of the options currently present, if possible. |
So you're currently using such a config? I'm asking because I really don't know how these options could be useful in the long run. They seem to be something one would run once in a terminal, not every time the service starts.
In my opinion, above mentioned options should be removed, they don't really fit into a declarative configuration. Note that users can still have such functionality by customizing the service as described above. A systemd timer that regularly imports files from specified directories seems fine though, if you want to add that. |
I know, and it's something I would like to fix upstream, but unfortunately because hydron doesn't check for new or changed images, so it needs to check every start via import, or perhaps like you suggest, on a timer so it doesn't slow down the boot process.
As I mentioned, that's an upstream issue and I'll remove the periodic imports once it is. For now, let's go with a systemd timer.
Good point, thanks for the tip. I'll remove it. |
@infinisil How does this look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that looks a lot better!
Hydron sounds very interesting, it's exactly what I need, will probably run it myself later :O
}; | ||
|
||
interval = mkOption { | ||
type = types.string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be types.str
|
||
importPaths = mkOption { | ||
type = types.nonEmptyListOf types.path; | ||
default = [ (cfg.dataDir + "/images") ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to use types.listOf types.path
, default = []
, and always try to import dataDir + "/images"
. if the user doesn't want to use it, they can just not put pictures in there, so this option is reserved for user specified directories.
|
||
preStart = '' | ||
# Ensure folder exists and permissions are correct | ||
mkdir -p ${cfg.dataDir}/images ${concatStringsSep " " cfg.importPaths} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Along with the importPaths
suggestion, this should be just mkdir -p "${cfg.dataDir}/images"
, the user managed directories shouldn't be touched.
# Ensure folder exists and permissions are correct | ||
mkdir -p ${cfg.dataDir}/images ${concatStringsSep " " cfg.importPaths} | ||
chmod 750 ${cfg.dataDir} | ||
chown -R hydron:hydron ${cfg.dataDir} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "
around ${cfg.dataDir}
, will make bash happy with some weird directory names.
description = "Import paths into hydron and fetch tags"; | ||
|
||
script = '' | ||
${pkgs.hydron}/bin/hydron import ${concatStringsSep " " cfg.importPaths} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Along with the importPaths
suggestion, you can add "${dataDir}/imports"
here. Also: You can use lib.escapeShellArgs cfg.importPaths
here instead to handle the escaping. (lib.escapeShellArg
could be used as well for the mkdir
above, maybe a bit excessive though)
|
||
script = '' | ||
${pkgs.hydron}/bin/hydron import ${concatStringsSep " " cfg.importPaths} | ||
'' + optionalString (cfg.fetchTags) '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Parens aren't needed
|
||
groups.hydron = { | ||
gid = config.ids.gids.hydron; | ||
members = [ "hydron" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should work without specifying this, since the user is declared to have hydron as the primary group already above.
pkgs/servers/hydron/default.nix
Outdated
goDeps = ./deps.nix; | ||
|
||
src = fetchFromGitHub { | ||
inherit rev; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Place the rev
definition here, because it's not needed as a drv attribute.
@infinisil Glad to see you like hydron, I've been using it and it's great. Especially being able to drag and drop images. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Only thing to do is squash all commits into one for the package and one for the module
No, addTags and removeTags only affects user-specified tags. Hydron maintains a separate set of tags depending on who set them (user, Gelbooru, Hydrus, etc.). fetch_tags only affects gelbooru-sourced tags. All tags are intersected on data request. Only the tag source can modify tags set by it.
That's a one time copy-based CLI commnad. It copies the matched file(s) to an internal database on request and populates metadata for them.
It really should not. You should import with the -f flag. Import + fetch_tags only makes sense on the initial import, which tends to be very large. |
I thought it was the opposite? |
That means large amounts of files that are not imported (thousands). Files that you try to import, but are already imported, will be hash-compared and ignored. |
Okay, that should do it. |
Hmm, but I mean, if I were to try out hydron, I'd first start the service, it would create the dataDir/images, and touch the once file (in your current implementation). And then I will put my 2000 files in there, it imports it via -f and is slow because of that. So this current solution certainly isn't very good. Why does it support 2 ways of doing that anyways ( |
The current solution has hydron check if the once file exists, and then if it doesn't, it uses |
Also, the |
Yeah, but the folder hydron uses to import only exists once it has started, so the chance of the once file technique actually working as intended is rather small, since it probably always exists once the user actually imports files. And when the user later adds his own directories with importPaths, they won't get imported via |
As @bakape said, the fetch_tags is really only for the first time, after that, -f is fine. |
@infinisil |
@Chiiruno
Why the fuck? Why would you ever DoS gelbooru like that? Imagine you have 10k images. Why would you refetch tags for all of them every hour? |
Well, that wasn't really my intention. Perhaps daily instead? |
Also why is this a problem if we're using |
But I mean for initial runs, -f is the same as fetch, because your database was empty, so added pictures = all pictures. So I also feel like always using -f should be fine, will make the service simpler as well. Edit: And less stateful and more predictable |
Yeah, using |
Imo that shouldn't be part of our problem: hydron should expect users to import a lot of files in one swoop and handle (if it has that) gelboorus rate limits, or implement rate limiting itself. E.g. nix-index handles this by limiting the number of active requests to be always <100. |
Weekly would be more apt.
It's not a problem, if you use -f. -f only fetches for freshly imported files. @infinisil |
That is not exactly what I meant. Hydron already limits to 8 concurrent API requests. What I meant is, if I'm the Gelbooru admin and see that every hour some faggot makes 10k API requests, I will block him. I might even have scripts to flag this as abuse and block him automatically. The end user should not be aware of this possibility. |
@bakape I see, but that won't be a problem with -f, right? If so, I think always using -f (even on the initial run) should be preferred. |
@infinisil |
@infinisil Ready again. |
Looking good to me! One last thing: Commit message for the module should be "nixos/hydron: init" @bakape Also looking good to you? |
I don't know much about NixOS. Somebody was being wrong on the internet and
I can't have that.
…On 18 July 2018 at 17:56, Silvan Mosberger ***@***.***> wrote:
Looking good to me! One last thing: Commit message for the module should
be "nixos/hydron: init"
@bakape <https://github.com/bakape> Also looking good to you?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#43308 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AHfPsIxslxx3GUO085RZNs-M4MWqYgW7ks5uH0y4gaJpZM4VKQTM>
.
|
Classic ;) |
@infinisil Am I finally free? |
You are finally free, thanks a lot! |
Motivation for this change
A nice and performant image tagger and sorter.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)