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

automatic peco install on julia>=1.3 #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

rapus95
Copy link

@rapus95 rapus95 commented Jan 14, 2020

This was the shortest change I had been able to come up with.
It now downloads in any case but uses the systems peco if available. (Otherwise it uses the artifact)

Fixes #6 for Julia>=1.3

Edit: I even managed to increase coverage 🤣

EDIT2: Seems to be far from idiomatic usage of the new artifacts & jll. Thus, do not merge yet! Eventually this needs a bigger rewrite.

@rapus95 rapus95 mentioned this pull request Jan 14, 2020
@rapus95 rapus95 closed this Jan 14, 2020
@tkf
Copy link
Owner

tkf commented Jan 15, 2020

Thanks for the PR.

BTW, I'm OK with dropping julia 0.7 if that's the blocker.

@rapus95
Copy link
Author

rapus95 commented Jan 15, 2020

It's not the 0.7 but my current usage of peco(identity) as I was told in the slack thread. I'll reopen it but will try to redesign it to match how it should be used.

For that we need a new interactive_matcher design.

@rapus95 rapus95 reopened this Jan 15, 2020
@codecov-io
Copy link

codecov-io commented Jan 15, 2020

Codecov Report

Merging #10 into master will increase coverage by 0.57%.
The diff coverage is 93.75%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #10      +/-   ##
=======================================
+ Coverage   73.42%   74%   +0.57%     
=======================================
  Files           4     4              
  Lines         350   350              
=======================================
+ Hits          257   259       +2     
+ Misses         93    91       -2
Impacted Files Coverage Δ
src/InteractiveCodeSearch.jl 89.5% <93.75%> (+1.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c442ab...c43e21a. Read the comment docs.

@rapus95 rapus95 force-pushed the master branch 3 times, most recently from b423019 to 316cef3 Compare January 16, 2020 13:05
@rapus95
Copy link
Author

rapus95 commented Jan 16, 2020

Now it might be ready to go, but I found that the visual history of what's been written previously just vanishes after the query.

EDIT: Fixed tests

@rapus95
Copy link
Author

rapus95 commented Jan 16, 2020

After force pushing like 5 times, I MIGHT managed to fix everything.

Who expects that tests are written with setfield! 😁

EDIT: cat is not a valid executable on windows -> Tests on Windows will always error

@rapus95
Copy link
Author

rapus95 commented Jan 16, 2020

Now 0.7 results in unsatisfiable constraints because peco_jll has constrained julia to be >=1. So maybe we should drop it now. But tbh why would anyone stay on 0.7?

@rapus95
Copy link
Author

rapus95 commented Jan 16, 2020

Btw why there are no CI jobs for JL 1.2 and 1.3? (And soon 1.4)

@tkf
Copy link
Owner

tkf commented Jan 16, 2020

For that we need a new interactive_matcher design.

Did you see #6 (comment)? What do you think about implementing Option 2 here?

Now 0.7 results in unsatisfiable constraints because peco_jll has constrained julia to be >=1.

Sounds good. Please bump the minor version of InteractiveCodeSearch.jl in Project.toml as well when doing this.

Btw why there are no CI jobs for JL 1.2 and 1.3? (And soon 1.4)

Good catch. I forgot to add them. Let's add them here as 1.3 is necessary for _jll test.

abstract type SearchPolicy end
struct Shallow <: SearchPolicy end
struct Recursive <: SearchPolicy end


mutable struct SearchConfig # CONFIG
open
interactive_matcher::Cmd
interactive_matcher::Function
Copy link
Owner

Choose a reason for hiding this comment

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

This breaks backward-compatibility. Let's still support

CONFIG.interactive_matcher = 

and just remove ::Cmd. The idea is to use run-time dispatch: #6 (comment)

setmatcher!(convertCmd(cmd), obj)
end

function convertCmd(cmd)
Copy link
Owner

Choose a reason for hiding this comment

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

Please use snake_case.

src/InteractiveCodeSearch.jl Outdated Show resolved Hide resolved
Co-Authored-By: Takafumi Arakaki <takafumi.a@gmail.com>
@rapus95
Copy link
Author

rapus95 commented Jan 17, 2020

Did you see #6 (comment)? What do you think about implementing Option 2 here?

I didn't see it. Regarding CONFIG.interactive_matcher = we also could customize getproperty, though, as you neither exported CONFIG nor CONFIG.interactive_matcher it can be questioned wether that's a breaking change since we can consider that stuff implementation detail which can be subject to change (And changing for a new minor version of Julia sounds legit to me). Since accessing fields usually is bad style in Julia anyway I'm curious why you want to retain that style rather than switching to some setmatcher! function.

@tkf
Copy link
Owner

tkf commented Jan 17, 2020

as you neither exported CONFIG nor CONFIG.interactive_matcher it can be questioned wether that's a breaking change since we can consider that stuff implementation detail

CONFIG is a public API because it is documented: https://github.com/tkf/InteractiveCodeSearch.jl#interactivecodesearchconfig

Since accessing fields usually is bad style in Julia anyway

I think it's a totally valid style as long as it is documented (i.e., a public API). See, e.g., DataFrames.jl and Tables.jl. Also, this CONFIG.<property_name> = <value> style is used elsewhere too:

OK, full disclosure, these are all initially added by me. But I didn't have major backlash so I'm assuming that it's a valid interface.

@rapus95
Copy link
Author

rapus95 commented Jan 17, 2020

So what do you think about the get/setproperty function?
Btw, removing ::Cmd would be breaking then aswell because if for whatever reason someone decides to read that attribute he won't necessarily get a cmd object anymore. (especially if reading the default we set.) if only writing to it then setproperty! might be able to solve everything.

@tkf
Copy link
Owner

tkf commented Jan 17, 2020

So what do you think about the get/setproperty function?

Do you mean to do the conversion via setproperty!? I think it's a possible solution. But I'm reluctant to do this as it breaks the property

CONFIG.interactive_matcher = value
@assert CONFIG.interactive_matcher == value

It's OK to break it sometimes (especially in the class-based OOP) but I'd like to avoid it if possible.

whatever reason someone decides to read that attribute he won't necessarily get a cmd object anymore

That's a fair point but I only document it for setting things. Also, overloading setproperty! breaks the "read API" more (as it breaks the above property).

@rapus95
Copy link
Author

rapus95 commented Jan 17, 2020

Either way will be breaking, so how about doing a fair cleanup (and bumping the major version)? Aka condensing the code we need and adding an explicit interface via methods

@tkf
Copy link
Owner

tkf commented Jan 17, 2020

As I said, I don't think CONFIG.<property_name> = <value> is a bad interface. In fact I think it has nice properties for configuration system:

  • Consistent get/set method. No need for defining separate methods get<property_name> and set<property_name>! where they are paired only by naming convention.
  • Configurable properties are documented in a single place (i.e., ?InteractiveCodeSearch.CONFIG works).
  • Configurable properties can easily be TAB-completed.

@rapus95
Copy link
Author

rapus95 commented Jan 17, 2020

While it's true that CONFIG seems to be a good place, having interactive_matcher untyped doesn't seem so. Tab completion doesn't help if you can't infer which type you need to provide. A setmatcher! would overcome that by providing the necessary info even if there are no docs. 😄
Either way, to me that object-y design feels somewhat uncomfortable but after adding peco via artifacts I don't intend to ever use that interface anyway 😁

@tkf
Copy link
Owner

tkf commented Jan 17, 2020

A setmatcher! would overcome that by providing the necessary info even if there are no docs.

Unfortunately, it doesn't. In Julia, every type is potentially callable. So, for hypothetical API setmatcher!, the signature we must use is setmatcher!(callable::Any). No type checking is possible at set-time and we can't use type annotation as "documentation."

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.

peco not installed
3 participants