Skip to content

Conversation

@FabrizioSandri
Copy link
Owner

Description

The purpose of this pull request is to improve the logging system of RcppDeepState.
In this way developers that will be able to rapidly identify any issues that may arise using this library.

@FabrizioSandri
Copy link
Owner Author

With the last few commit I improved the logging system when some functions being analyzed contains as argument data types that are not allowed.

In detail, the function deepstate_pkg_create fails if developers try to run the TestHarness creation procedure on a library with functions containing in their signature (the argument list), data types which are not allowed with the following error message:

Testharnesses cannot be created for the package - datatypes fall out of specified list!!

This has been improved, printing for each function not analyzed, the list of parameters that fall out of the allowed list.

@FabrizioSandri
Copy link
Owner Author

Since importing RInside in the R code is not essential, I deleted it from the imports in the most recent commits. There is no need to import RInside because it is already there in the DESCRIPTION file, in the dependencies list. RInside will instead be imported and used inside the C++ code.

Additionaly I discovered that certain code parts require a little bit of review. For instance, there are parts of the code that are not used, such variable definitions. For example, I deleted the following line in the commit b012edb.

prototypes_calls <-deepstate_get_prototype_calls(package_path)

Because RcppDeepState is all about speed and performance to run the tests, even little adjustments like this one may have some impact.

@FabrizioSandri
Copy link
Owner Author

With the most recent updates, I added the verbose argument to various RcppDeepState methods. This option is used to offer more detailed information if it is set to TRUE. This parameter uses the value from the global option verbose by default.

@FabrizioSandri
Copy link
Owner Author

@tdhock do you think I need to make any other adjustments? I plan to review again the logging part later on.
To allow you to review these changes, I have sent you an invite to participate as a collaborator.

branches: [test-debug-symbols, logging-improvements]
pull_request:
branches: [test-debug-symbols]
branches: [test-debug-symbols, logging-improvements]
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there some way to specify all branches?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, I modified the workflow such that the "R CMD check" command is run on each branch.
Fixed in commit 6b85147

}
for(pkg.i in seq_along(test.files)){
list_testfiles[basename(test.files[[pkg.i]])] <- list(deepstate_analyze_fun(path,basename(test.files[[pkg.i]]),max_inputs))
list_testfiles[basename(test.files[[pkg.i]])] <- list(deepstate_analyze_fun(path,basename(test.files[[pkg.i]]), max_inputs, verbose))
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use double square brackets on left side of <- and remove list() from right side

Copy link
Owner Author

Choose a reason for hiding this comment

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

I solved this in the commit 1d7e9cc

R/get-pkgs.R Outdated



return(list(1,c()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

explicit return is not needed at end of function, please remove.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I completely reviewed the entire function and changed it's name to deepstate_get_mismatched_datatypes. Now his function returns the list of mismatched arguments, instead of returning 0 or 1 alongside with the mismatched datatypes.

R/get-pkgs.R Outdated
Comment on lines 8 to 9
datatypes <- list("NumericVector","NumericMatrix" ,"arma::mat","double",
"string","CharacterVector","int","IntegerVector")
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is the list of supported data types right? So rather than "mismatched" in the function name maybe "unsupported" would be more appropriate?
Also this list is redundant with the logic in https://github.com/FabrizioSandri/RcppDeepState/blob/master/R/fun_harness_create.R -- if you have time it would be good to reorganize that code so that a list or table is used to lookup what to do, rather than the current code which is rather difficult to understand (lots of if/else statements).

Copy link
Owner Author

@FabrizioSandri FabrizioSandri Jul 11, 2022

Choose a reason for hiding this comment

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

That's true, this list is redundant. I updated the deepstate_fun_create function inside fun_harness_create.R and replaced the if else statements with a table containing information for the supported datatypes. In detail each column of this table corresponds to a supported datatype and provides some details on it. The first row of this table contains an alternative datatype to be used when saving the inputs(e.g., using qs::c_qsave), whereas the second row correspond to the associated generation function that takes as input a range. When a datatype contains a value of NA in both rows, it means that is supported, utilizes itself when executing qs::c_qsave and lacks a range function. In this way checking if a datatype is supported is really simple: just check if exists a column for the datatype in this table.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I think the function deepstate_get_unsupported_datatypes may now be removed.

@tdhock
Copy link
Collaborator

tdhock commented Jul 12, 2022

for the list of supported types, instead of one column per type please try one row per type like this:

datatype <- function(ctype,rtype,args)data.table(ctype,rtype,args)
types_table <- rbind(
  datatype("int", "IntegerVector", "(low,high)"),
  datatype("double", "NumericVector", "(low,high)"))
setkey(types_table, ctype)
type_info <- types_table[my_type]
type_info$args

@FabrizioSandri
Copy link
Owner Author

@tdhock I replaced the list of supported datatypes with the types_table you mentioned in your previous comment and discussed in the Google meet of Tuesday.

}
for(pkg.i in seq_along(test.files)){
list_testfiles[[basename(test.files[[pkg.i]])]] <- deepstate_analyze_fun(path,basename(test.files[[pkg.i]]), max_inputs, verbose)
list_testfiles[[basename(test.files[[pkg.i]])]] <- deepstate_analyze_fun(path,basename(test.files[[pkg.i]]), max_inputs, verbose=verbose)
Copy link
Collaborator

Choose a reason for hiding this comment

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

since you use basename(test.files[[pkg.i]]) twice please create an intermediate variable

Copy link
Owner Author

@FabrizioSandri FabrizioSandri Jul 23, 2022

Choose a reason for hiding this comment

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

Done! Updated in the commit 7b4d7e9

@FabrizioSandri FabrizioSandri merged commit 7b2220d into master Jul 26, 2022
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.

3 participants