-
Notifications
You must be signed in to change notification settings - Fork 69
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
adding peru override watch #163
base: master
Are you sure you want to change the base?
Conversation
Not sure what checks are failing, but I'm happy to change/fix whatever you want. |
Thanks for the PR! I'm just starting to take a look, but it looks like the test failures are actually just lint warnings:
If you run |
Could you please tell me more about your workflow? I know almost nothing about how people use override in the real world, and I'm really interested to learn more. |
My initial reaction is that I'd prefer to avoid taking this sort of dependency inside peru itself, if we could handle the same sort of use case with external tools. Would it be possible to handle your workflow with a Watchman trigger? Triggering build commands was the first use case Watchman was designed for, so I expect it would work very well with peru. Filesystem watching tends to have a lot of complications and corner cases, and I'd be curious how watchdog and Watchman compare in cases like rapid updates to many files:
and atomic-file-moving-instead-of-in-place-editing:
Very curious to hear your thoughts on those questions, @spasarok. Also @olson-sean-k. Apart from the broad discussion above, I'll go ahead and comment inline with feedback for this PR specifically. |
logging.info('moved %s: from %s to %s', what, event.src_path, | ||
event.dest_path) | ||
logging.info('running peru sync --force') | ||
os.system('peru sync --force') |
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.
We'd probably want some way to control whether syncs are done with --force
or not. Maybe with a --force
flag on the watch
command?
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.
Rather than shelling out with os.system
, we'd probably want to call directly into imports.checkout
the way that do_sync
does. That would mean that these functions would need to be coroutines.
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.
Peru doesn't currently do any kind of filesystem locking to prevent running multiple commands in parallel in the same project. But if you do that, it could cause weird conflicts and errors. We should definitely add proper locking at some point, but it still also probably makes sense for a watcher to avoid queueing up several waiting instances at once (or running commands that will error out, depending on how we want to implement lock contention).
Hello! Thanks for the discussion. I'll respond in order. Could you please tell me more about your workflow? I know almost nothing about how people use override in the real world, and I'm really interested to learn more. We use Peru for WordPress development. WordPress uses themes to style sites and plugins to provide functionality independent of a site theme. Each site that we build has a general repo with the site theme and we use Peru to sync plugins and other dependencies. This workflow is great for most dependencies, but sometimes we're syncing plugins that we're still in the middle of developing. In these cases we have to run peru sync pretty continuously in order to test changes to whatever plugin we're developing. This can be tedious and break up the workflow, especially when testing many small atomic changes in quick succession. I was thinking that it could be useful to have a watch command for Peru, sort of like the watch command that Compass uses to compile Sass to CSS (http://compass-style.org/help/). This would allow the workflow for testing dependency development to go from text editor -> terminal -> browser to simply text editor -> browser. |
Would it be possible to handle your workflow with a Watchman trigger? I'm happy to look into this. |
We'd probably want some way to control whether syncs are done with --force or not. Maybe with a --force flag on the watch command? Forcing can definitely use a flag instead. I grappled with this topic for a bit, but I ultimately decided to force --force for the following reasons:
However, I agree that it's much safer to simply require --force than to make the assumptions above, so I'm totally on board with that. |
Rather than shelling out with os.system, we'd probably want to call directly into imports.checkout the way that do_sync does. That would mean that these functions would need to be coroutines. Sounds good. I ran into some issue trying to use imports.checkout in the runtime file, but I'll delve into it a little more. |
The display object (usually runtime.display) has a print method that lets us do regular printing in a way that doesn't screw up the redrawing. Sweet, I'll take a look at it. |
Very cool. I bet Watchman is going to be perfect for this. It'll also be more flexible if your workflow grows in the future to include codegen/compilation/restarting before or after the peru sync. Either way, I'm going to need to get back to #115 at some point, to get ahead of some of the cache corruption issues that might come up here with multiple peru processes running. |
Hey @oconnor663, co-worker of @spasarok here. We're starting to use Modd for our general watching/building needs. At a glance, it looks to me like it it fills the same niche as Watchman. We've only got it in 4 or 5 projects so far, so switching to Watchman might be something we'd do. But to maybe shed some light on how we're using overrides and how our current watching works, here're a couple of snippets from some of our
When either This is great but we don't know of anything to watch in the Peru-using repo's world that'd tell us if the override's content changes. My first thought is using symlinks in With other programs like Compass or MkDocs that have a built-in watcher, we tell Modd to delegate its watching like this:
In this quasi-contrived case, it runs So if Peru had a built-in
...or...
...and we'd have one fewer thing to manually manage in our workflow. |
I'd really like to leave this to external tools, and it seems like overrides are the only tricky part. The names and paths of overrides are trivial to query, so I think the right way to support this may be to provide complete and machine-readable output about overrides for external tools to consume. For example, we could provide a Machine-readable output for query commands may be useful in general (see #165), so we could consider providing a I'm not sure what this would mean for your modd configuration, since something would have to notice override changes and update the paths that are being watched. It may still be necessary to watch |
By the way, if you guys would like to schedule a group video chat or something like that to brainstorm about this stuff, I'd be up for it. |
@olson-sean-k Yeah, overrides are the only tricky part that we've gotten completely stuck on here. I think a Not much would change in our |
I feel like the question of whether or not this kind of functionality is appropriate for Peru itself comes down to... how much "batteries included" does Peru want to be? @oconnor663 I'd definitely be up for a group chat to brainstorm with you and @spasarok sometime. |
Sure, I'm down for a group chat. @oconnor663 and @olson-sean-k what time works best for you? |
We did it! https://youtu.be/YxSsRztjMec My notes. Please add anything I left out. TODO new peru features in bold.
|
Since I've already got some general future plans written down in this issue, I'm just going to add more here :) Takeaways from our meetup yesterday, other folks please add more:
|
@olson-sean-k just added the |
Hello! I made a peru override watch command to automatically sync overrides when they change. I was wondering you would be willing integrate this or something similar into Peru. It would be super helpful for my and some of my teammates' workflows. Thanks!