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

Exported variable starting with a period are not loaded #103

Closed
2 tasks
HenrikBengtsson opened this issue Sep 13, 2015 · 2 comments
Closed
2 tasks

Exported variable starting with a period are not loaded #103

HenrikBengtsson opened this issue Sep 13, 2015 · 2 comments
Labels

Comments

@HenrikBengtsson
Copy link
Contributor

Although batchExport() successfully exports variables starting with periods, they are not loaded in the job sessions. This is in turn because loadExports() does not load those variables.

Example

> library(BatchJobs)
> reg <- makeRegistry(id="test")
> objs <- list(a=1, b=2, .c=3, d=4)
> str(objs)
List of 4
 $ a : num 1
 $ b : num 2
 $ .c: num 3
 $ d : num 4
> batchExport(reg, li=objs)
> keys <- loadExports(reg)
Loading RData files: a,b,d
> keys
[1] "a" "b" "d"

Troubleshooting

All four variables are indeed exported:

> list.files(path=BatchJobs:::getExportDir(reg$file.dir), all.files=TRUE, no..=TRUE)
[1] ".c.RData" "a.RData"  "b.RData"  "d.RData"

But the ls() method for fail objects in loadExports() uses the default all.files=FALSE;

> library(fail)
> f = fail(BatchJobs:::getExportDir(reg$file.dir), extension = "RData", simplify=TRUE)
> f$ls()
[1] "a" "b" "d"
> f$ls
function (pattern = NULL)
{
    Ls(.self, pattern)
}
<bytecode: 0x000000000c108dc8>
<environment: 0x000000000c715348>
> fail:::Ls
function (.self, pattern = NULL)
{
    keys = fn2key(.self, list.files(.self$path, pattern = sprintf("\\.%s$",
        .self$extension)))
    if (!is.null(pattern))
        keys = keys[grepl(pattern, keys)]
    return(keys)
}
<bytecode: 0x000000000afff9b8>
<environment: namespace:fail>

Suggestions

  • At a minimum, batchExport() should give an error, or at least a warning, if variable names starting with a period are specified, cf. Issue batchExport() and objects with non-standard names #93.
  • If fixed, the list.files() call of fail:::Ls() needs all.files=TRUE in order to pick up variables starting with a period. Simple tests, indicates that this is enough, that is, with .c in keys, then f$assign(keys, envir = .GlobalEnv) does indeed load and assign .c to the global environment.
@mllg
Copy link
Member

mllg commented Oct 6, 2015

Should be fixed with fail v1.3 and 7ab2e11.

@mllg mllg closed this as completed Oct 6, 2015
@HenrikBengtsson
Copy link
Contributor Author

Thxs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants