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

asearch function usage #149

Closed
wchodor opened this issue Nov 30, 2015 · 22 comments
Closed

asearch function usage #149

wchodor opened this issue Nov 30, 2015 · 22 comments

Comments

@wchodor
Copy link
Collaborator

wchodor commented Nov 30, 2015

@pbiecek
I am in the course of reviewing asearch function and I'm wondering what was your goal. Were you planning to extend its functionality on local repository? This part of asearch function's body indicates that we want to search and read from local repo too. But it can be only default local repo.

if (is.null(repo)) {
    # use default repo
    oblist <- multiSearchInLocalRepo(patterns = patterns,
                                      intersect = TRUE)
    if (length(oblist)>0) {
      res <- lapply(oblist, aread)
    } 
  }

I am a little bit confused because the documentation suggests that we want to work on Github Repository only.

@MarcinKosinski
Copy link
Collaborator

I think it's just the matter of obsolete documentation.

@pbiecek
Copy link
Owner

pbiecek commented Nov 30, 2015

The documentation is to be updated.
My goal is to cover to options:
If there is any '/' then it search in github repo,
If there is no / then it search in the default repo, either local or github.

P

Dnia 30.11.2015 o godz. 14:20 Witold Chodor notifications@github.com napisał(a):

@pbiecek
I am in the course of reviewing asearch function and I'm wondering what was your goal. Were you planning to extend its functionality on local repository? This part of asearch function's body indicates that we want to search and read from local repo too. But it can be only default local repo.

if (is.null(repo)) {
# use default repo
oblist <- multiSearchInLocalRepo(patterns = patterns,
intersect = TRUE)
if (length(oblist)>0) {
res <- lapply(oblist, aread)
}
}
I am a little bit confused because the documentation suggests that we want to work on Guthub Repository only.


Reply to this email directly or view it on GitHub.

@wchodor
Copy link
Collaborator Author

wchodor commented Nov 30, 2015

OK, I understand.
But the actual code won't work for default Github repository. I will try to fix it.

@pbiecek
Copy link
Owner

pbiecek commented Nov 30, 2015

Would be great if you can take care of it.

2015-11-30 16:14 GMT+01:00 Witold Chodor notifications@github.com:

So tha actual code won't work for Github default repository. Do you want
me to take care of it?


Reply to this email directly or view it on GitHub
#149 (comment).

pozdrawiam serdecznie,
Przemysław Biecek

@wchodor
Copy link
Collaborator Author

wchodor commented Dec 1, 2015

@pbiecek
I made some changes and now it is working. I would appreciate if you tell me whether such changes meet you expectations. Here is the link to commit:
https://github.com/wchodor/archivist/commit/b7bef3279b8e8ba6fb0a85c43f1e7015b2f41811

@wchodor
Copy link
Collaborator Author

wchodor commented Dec 1, 2015

@MarcinKosinski @pbiecek
What is more I suggest removing default parameter from createEmptyLocalRepo function.
First of all because of the fact that it is not used in createEmptyGithubRepo.
Secondly asearch won't work with default=TRUE argument in createEmptyLocalRepo.

@MarcinKosinski
Copy link
Collaborator

There's an issue for default parameter in createEmptyGithubRepo:
#143

Why asearch won't work with default=TRUE argument in createEmptyLocalRepo?

2015-12-01 18:04 GMT+01:00 Witold Chodor notifications@github.com:

@MarcinKosinski https://github.com/MarcinKosinski @pbiecek
https://github.com/pbiecek
What is more I suggest removing default parameter from
createEmptyLocalRepo function.
First of all because of the fact that it is not used in
createEmptyGithubRepo.
Secondly asearch won't work with default=TRUE argument in
createEmptyLocalRepo.


Reply to this email directly or view it on GitHub
#149 (comment).

@wchodor
Copy link
Collaborator Author

wchodor commented Dec 1, 2015

Because of setLocalRepo. I assumed that type parameter is loaded into .ArchivEnv in setRepo function. So when you are using createEmptyRepo with default=TRUE parameter then setLocalRepo is used and type is not loaded. As a result multiSearchInRepo in asearch gives an error.

@MarcinKosinski
Copy link
Collaborator

So maybe createEmptyRepo with default=TRUE should also change global type
parameter?

2015-12-01 18:15 GMT+01:00 Witold Chodor notifications@github.com:

Because of setLocalRepo. I assumed that type parameter is loaded into
.ArchivEnc in setRepo function. So when you are using createEmptyRepo
with default=TRUE parameter then type is not loaded. And multiSearchInRepo
in asearch gives an error.


Reply to this email directly or view it on GitHub
#149 (comment).

@wchodor
Copy link
Collaborator Author

wchodor commented Dec 1, 2015

Do you mean to put

aoptions( "type", type )

in createEmpty Repo' body?

@wchodor
Copy link
Collaborator Author

wchodor commented Dec 1, 2015

like this:

stopifnot(is.character(type) & length(type) ==1 & type %in% c("local", "github"))
if (default) 
    aoptions( "type", type )
  if (type == "local") {
    createEmptyLocalRepo(repoDir = repoDir, force = force, default = default)
  } else {

@MarcinKosinski
Copy link
Collaborator

if deafult == TRUE ?

2015-12-01 18:54 GMT+01:00 Witold Chodor notifications@github.com:

stopifnot(is.character(type) & length(type) ==1 & type %in% c("local", "github"))
aoptions( "type", type )
if (type == "local") {
createEmptyLocalRepo(repoDir = repoDir, force = force, default = default)
} else {


Reply to this email directly or view it on GitHub
#149 (comment).

@wchodor
Copy link
Collaborator Author

wchodor commented Dec 1, 2015

So, like this ?

  stopifnot(is.character(type) & length(type) ==1 & type %in% c("local", "github"))
  if (default) aoptions("type", type)
  if (type == "local") {
    createEmptyLocalRepo(repoDir = repoDir, force = force, default = default)
  } else {

@MarcinKosinski
Copy link
Collaborator

Looks good. Pleas do the change and submit PR

2015-12-01 18:58 GMT+01:00 Witold Chodor notifications@github.com:

stopifnot(is.character(type) & length(type) ==1 & type %in% c("local", "github"))
if (default) aoptions("type", type)
if (type == "local") {
createEmptyLocalRepo(repoDir = repoDir, force = force, default = default)
} else {


Reply to this email directly or view it on GitHub
#149 (comment).

@pbiecek
Copy link
Owner

pbiecek commented Dec 1, 2015

Why do we need 'type = aoptions("type")' ?
It looks like a duplication, since the loadFromRepo() function can decide
if someone is asking for local repo (repoDir is set)
or github repo (repo is set).

it is actually a possible vulnerability since default value of type may not
be consistent with default value of repoDir/repo.

2015-12-01 17:56 GMT+01:00 Witold Chodor notifications@github.com:

@pbiecek https://github.com/pbiecek
I made some changes and now it is working. I would appreciate if you tell
me whether such changes meet you expectations. Here is the link to commit:
wchodor@b7bef32
https://github.com/wchodor/archivist/commit/b7bef3279b8e8ba6fb0a85c43f1e7015b2f41811


Reply to this email directly or view it on GitHub
#149 (comment).

pozdrawiam serdecznie,
Przemysław Biecek

@pbiecek
Copy link
Owner

pbiecek commented Dec 1, 2015

Regarding the 'default' parameter (let's use separate issues for separate
problems),
I would rather fix asearch (to make it working with default local repo) and
createEmptyGithubRepo (which is still in development I believe)

2015-12-01 18:04 GMT+01:00 Witold Chodor notifications@github.com:

@MarcinKosinski https://github.com/MarcinKosinski @pbiecek
https://github.com/pbiecek
What is more I suggest removing default parameter from
createEmptyLocalRepo function.
First of all because of the fact that it is not used in
createEmptyGithubRepo.
Secondly asearch won't work with default=TRUE argument in
createEmptyLocalRepo.


Reply to this email directly or view it on GitHub
#149 (comment).

pozdrawiam serdecznie,
Przemysław Biecek

@pbiecek
Copy link
Owner

pbiecek commented Dec 1, 2015

The fact that you need to synchronise changes in 'type' and 'repoDir' is an
argument against using type as a parameter.
Instead of that (if we really need type, I am not convinced) it may be a
function which will decide if the definition of a repository matches local
repo or github repo (it can be decided based of names of arguments).

2015-12-01 19:01 GMT+01:00 Marcin Kosiński notifications@github.com:

Looks good. Pleas do the change and submit PR

2015-12-01 18:58 GMT+01:00 Witold Chodor notifications@github.com:

stopifnot(is.character(type) & length(type) ==1 & type %in% c("local",
"github"))
if (default) aoptions("type", type)
if (type == "local") {
createEmptyLocalRepo(repoDir = repoDir, force = force, default = default)
} else {


Reply to this email directly or view it on GitHub
<#149 (comment)
.


Reply to this email directly or view it on GitHub
#149 (comment).

pozdrawiam serdecznie,
Przemysław Biecek

@wchodor
Copy link
Collaborator Author

wchodor commented Dec 1, 2015

I understand your point of view.
I will try to think how to fix this in the way you say.

@wchodor
Copy link
Collaborator Author

wchodor commented Dec 1, 2015

@pbiecek
I made some changes regarding your hints. Above, you have my commit.

pbiecek added a commit that referenced this issue Dec 1, 2015
 Alterations in `asearch` and other functions due to #149 issue.
@pbiecek
Copy link
Owner

pbiecek commented Dec 1, 2015

Thanks,
btw: maybe we can add to the wiki list of parameters, that can be set via 'aoptions'?
Then it will be easier to see parameters like 'type'

@wchodor
Copy link
Collaborator Author

wchodor commented Dec 1, 2015

When it comes to type I removed it and used repoDir and repo arguments to detect whether repository is local or GitHub.
As for now type parameter is only in createEmptyRepo. I thought that you suggested not to use it. And I think that it was a good idea. I proposed such a solution (e.g. for loadFromRepo):

loadFromRepo <- function( md5hash, repoDir = NULL,
                          repo = NULL, user = NULL, branch = "master", repoDirGit = FALSE,
                          value = FALSE ){

  local <- (!is.null(aoptions("repoDir")) && is.null(repo)) || (!is.null(repoDir) && is.null(repo))
  GitHub <- (is.null(repoDir) && !is.null(aoptions("repo"))) || (is.null(repoDir) && !is.null(repo))
  if (local) {
    loadFromLocalRepo( md5hash = md5hash, repoDir = repoDir, value = value )
  } else if (GitHub) {
    loadFromGithubRepo(  md5hash = md5hash, repo = repo, user = user, branch = branch,
                         repoDirGit = repoDirGit, value = value )
  } else {
    stop("repo and repoDir parameters can not be used simultaneously.")
  } 
}

@MarcinKosinski
Copy link
Collaborator

Ok looks good. If this is fixed, can you @wchodor close the issue?

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

No branches or pull requests

3 participants