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

Add package dependency network graph to the blueprint #1001

Closed
wants to merge 6 commits into from

Conversation

vedhav
Copy link
Contributor

@vedhav vedhav commented Dec 11, 2023

Hey, @insightsengineering/nest-core-dev 👋
What do you think about adding a package dependency network graph in our product map vignette of the blueprint?
It was super helpful for me to understand how different packages connect to each other.

This adds the network diagram to explore the package dependencies of the teal framework to the Technical Blueprint's Product Map.

It seems like more dependencies are added to suggests but only visNetwork and config are the new suggests and the rest of them are already indirect dependencies of teal.

P.S I used the four primary colors from the NEST logo for the node groups 😉

Copy link
Contributor

github-actions bot commented Dec 11, 2023

badge

Code Coverage Summary

Filename                          Stmts    Miss  Cover    Missing
------------------------------  -------  ------  -------  -------------------------------------------------------------------------------------------------------------------------------
R/dummy_functions.R                  97      88  9.28%    9-71, 93-106, 109-116, 131-146
R/get_rcode_utils.R                  32       1  96.88%   52
R/include_css_js.R                   24       0  100.00%
R/init.R                             96      31  67.71%   113-120, 177-178, 180, 192-213, 244-245, 247
R/landing_popup_module.R             25      25  0.00%    61-87
R/module_filter_manager.R           107      36  66.36%   49-55, 62-70, 79-84, 228, 233-246
R/module_nested_tabs.R              149      58  61.07%   64-137, 153, 205, 227, 253
R/module_snapshot_manager.R         209     157  24.88%   87-99, 127-136, 140-152, 154-161, 168-182, 186-188, 190-195, 198-208, 211-227, 236-251, 265-288, 291-302, 305-311, 325, 346-369
R/module_tabs_with_filters.R         73      33  54.79%   60-95, 127, 140
R/module_teal_with_splash.R         114       4  96.49%   87, 108, 174-175
R/module_teal.R                     141      33  76.60%   72, 83, 92, 166-167, 173, 204, 212-213, 235-267
R/modules_debugging.R                19      19  0.00%    25-45
R/modules.R                         151      33  78.15%   119, 131-139, 224-227, 244-248, 303-307, 397-440
R/reporter_previewer_module.R        18       2  88.89%   26, 30
R/show_rcode_modal.R                 20      20  0.00%    16-37
R/tdata.R                            53       1  98.11%   153
R/teal_data_module-eval_code.R       27       0  100.00%
R/teal_data_module-within.R           7       0  100.00%
R/teal_data_module.R                  6       0  100.00%
R/teal_reporter.R                    60       5  91.67%   65, 116-117, 120, 137
R/teal_slices-store.R                29       0  100.00%
R/teal_slices.R                      59      12  79.66%   135-148
R/utils.R                           141      28  80.14%   112-139, 296
R/validate_inputs.R                  32       0  100.00%
R/validations.R                      58      37  36.21%   109-371
R/zzz.R                              11       7  36.36%   3-14
TOTAL                              1758     630  64.16%

Diff against main

Filename      Stmts    Miss  Cover
----------  -------  ------  --------
TOTAL             0       0  +100.00%

Results for commit: ee66e8b

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

github-actions bot commented Dec 11, 2023

Unit Tests Summary

  1 files   19 suites   11s ⏱️
204 tests 202 ✅ 2 💤 0 ❌
421 runs  418 ✅ 3 💤 0 ❌

Results for commit 59d6b4b.

♻️ This comment has been updated with latest results.

- teal.osprey
- teal.goshawk
- teal.modules.clinical
- teal.modules.helios
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Question: Do we need teal.modules.helios here or do we add it here after the public release is made? If we only use public repos we don't need GitHub token to access the staged_dependencies.yaml and the pkgdown site will build without any issues.

@pawelru
Copy link
Contributor

pawelru commented Dec 11, 2023

Note that this is quite lengthy process to complete - are we good with that? Especially that it's in CI that got re-triggered quite frequently?

I feel that there could be much faster way of getting that information using pkgdepends that relies on metadata in DESC file and not cloning the whole repository.

Also, I really doubt such visualisation on the NEST level will give a lot of value. There are quite a few issues about deps already so this is nothing new I feel. If you want to enhance it more - I would prefer to think more repo-wise than project-wise. I think it could be more actionable.

@vedhav
Copy link
Contributor Author

vedhav commented Dec 12, 2023

Agree that staged_dependencies.yaml should not be used for this. Especially when we intend to remove them after the cran release is made (I'm surprised our CI will work without this file)
I do see some value from this. The mermaid graph in the product map is perfect in conveying the product architecture of teal however this does not convey the inter-dependencies between different teal core packages and it is easy to create a false mental model that teal.code, teal.data, and teal.* are imported into teal and they don't have much to do with each other. Someone has to go through each of the package dependency individually to understand this connection. This felt like the easiest way for showing this.

@gogonzo
Copy link
Contributor

gogonzo commented Dec 12, 2023

Especially when we openpharma/mmrm#383 after the cran release is made (I'm surprised our CI will work without this file)

I can't imagine work without staged.dependencies when testing feature branches. @main is covered by r-universe and releasing packages to CRAN doesn't add any value to the cicd process.

@pawelru
Copy link
Contributor

pawelru commented Dec 12, 2023

Agree that staged_dependencies.yaml should not be used for this. Especially when we intend to remove them after the cran release is made (I'm surprised our CI will work without this file)

Honestly, I am quite surprised seeing this and agree with what @gogonzo said. The staged-deps and CRAN should be independent. CRAN is a deployment repository and staged-deps allows to simulate mono-repo for multiple-repo development purposes. I'm not a big fan of this but it seems that sometimes it's needed - hence: we don't want to remove it (or more precisely: we are not ready to remove it).

I do see some value from this. The mermaid graph in the product map is perfect in conveying the product architecture of teal however this does not convey the inter-dependencies between different teal core packages and it is easy to create a false mental model that teal.code, teal.data, and teal.* are imported into teal and they don't have much to do with each other. Someone has to go through each of the package dependency individually to understand this connection. This felt like the easiest way for showing this.

OK - I understand. Then let's continue discussing. We can do this two ways:

  1. Modify the existing chart
    This means hard-coding dependency map and therefore it's likely that the information become outdated soon... Maybe we can try to be more conceptual than correct - e.g. just make a connection between teal.code and teal and don't go into the details on what kind of dependency it is etc. Just an idea how to address that problem... From what I can see now - that was the intention.

  2. Use some other functionality?
    Staged-deps was designed for something other. It's might be too slow (too powerful) just to present a dependency graph.
    Moreover, (like I said earlier) I am not a big fan of staged-deps and sooner or later I will bring it's need into the discussion. Right now it's too early because our products are being too dependent between each other. But we have made a significant progress on that regard. Let's see in the future.
    I mentioned pkgdepends earlier. Please find a snippet below to get the relevant data for getting the whole map. You can move forward from this.

x <- pkgdepends::new_pkg_deps(c("insightsengineering/teal", "insightsengineering/teal.data", "insightsengineering/teal.code", "insightsengineering/teal.slice"))
x$solve()
#> 
#> ✔ Updated metadata database: 4.88 MB in 8 files.
#> 
#> ℹ R 4.3 aarch64-apple-darwin20 packages are missing from Bioconductor
#> ℹ Updating metadata database
#> ✔ Updating metadata database ... done
#> 
y <- x$get_resolution()[, c("package", "direct", "deps")]

y
#> # A data frame: 213 × 3
#>    package     direct deps          
#>    <chr>       <lgl>  <list>        
#>  1 teal        TRUE   <tbl [50 × 5]>
#>  2 teal.data   TRUE   <tbl [18 × 5]>
#>  3 teal.code   TRUE   <tbl [21 × 5]>
#>  4 teal.slice  TRUE   <tbl [44 × 5]>
#>  5 BH          FALSE  <tbl [0 × 5]> 
#>  6 MASS        FALSE  <tbl [10 × 5]>
#>  7 Matrix      FALSE  <tbl [14 × 5]>
#>  8 R.cache     FALSE  <tbl [6 × 5]> 
#>  9 R.methodsS3 FALSE  <tbl [3 × 5]> 
#> 10 R.oo        FALSE  <tbl [5 × 5]> 
#> # ℹ 203 more rows
y[1, "deps"][[1]]
#> # A data frame: 50 × 5
#>    ref            type    package        op    version     
#>    <chr>          <chr>   <chr>          <chr> <chr>       
#>  1 R              Depends R              ">="  "4.0"       
#>  2 shiny          Depends shiny          ">="  "1.7.0"     
#>  3 teal.data      Depends teal.data      ">="  "0.3.0.9017"
#>  4 teal.slice     Depends teal.slice     ">="  "0.4.0.9027"
#>  5 teal.transform Depends teal.transform ">="  "0.4.0.9010"
#>  6 checkmate      Imports checkmate      ">="  "2.1.0"     
#>  7 jsonlite       Imports jsonlite       ""    ""          
#>  8 lifecycle      Imports lifecycle      ">="  "0.2.0"     
#>  9 logger         Imports logger         ">="  "0.2.0"     
#> 10 magrittr       Imports magrittr       ">="  "1.5"       
#> # ℹ 40 more rows

Created on 2023-12-12 with reprex v2.0.2

@vedhav vedhav added core documentation Improvements or additions to documentation labels Jan 24, 2024
@vedhav
Copy link
Contributor Author

vedhav commented Jan 24, 2024

Thank you @pawelru for suggesting a simpler way of fetching the dependencies.
Circling back on this as we're cleaning the vignettes before the CRAN release. What are your thoughts on showing the Dependencies of the teal packages like this.
Screenshot 2024-01-24 at 9 37 24 AM

@chlebowa
Copy link
Contributor

Personally, I don't find this particularly easy to read. I would have to stop thinking about text and focus on this graph for more than a minute to comprehend it OR give it a glance and ignore it and continue reading. Again, this is me personally, maybe other people may have an easier time with it.

Copy link
Contributor

@gogonzo gogonzo left a comment

Choose a reason for hiding this comment

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

Six extra dependencies in the Suggests just to make dependencies graph - I don't feel good with this.
Also, I don't think that user/developer learns a lot about the product by knowing what depends on what. This is redundant information IMO. We should picture how these relationships look like (and we do in the vignettes).

@gogonzo gogonzo self-assigned this Jan 24, 2024
@pawelru
Copy link
Contributor

pawelru commented Jan 24, 2024

Above points are valid. Please remove suggested packages not needed anymore as well as try to experiment with layout / direction of the graph and let's see what you came up with.

@vedhav
Copy link
Contributor Author

vedhav commented Jan 24, 2024

Sorry about that, removed the residual dependencies from the previous implementation. pkgdepends and visNetwork are the only two real dependencies for this, dplyr is anyway going to be installed as it's imported by teal.code teal.slice.
In the above mermaid diagram we show that teal -- has -> features (list of the features). However, this might mislead people into believing that all these packages are simply the direct dependencies of teal and have nothing to do with each other, which is not the case. After the CRAN release this information is not going to be practically helpful. But, it will certainly help people who would like to contribute, to understanding the inter-dependencies easily.

Updated the diagram to show the edges with "imports" and "depends", Flipped the direction so it makes sense and Improved the layout.
Screenshot 2024-01-24 at 5 37 48 PM

@chlebowa
Copy link
Contributor

dplyr is anyway going to be installed as it's imported by teal.code

It most certainly is not.

Type: Package
Package: teal.code
Title: Code Storage and Execution Class for 'teal' Applications
Version: 0.5.0.9000
Date: 2024-01-11
Authors@R (parsed):
    * Dawid Kaledkowski <dawid.kaledkowski@roche.com> [aut, cre]
    * Aleksander Chlebowski <aleksander.chlebowski@contractors.roche.com> [aut]
    * Marcin Kosinski <marcin.kosinski.mk1@roche.com> [aut]
    * Pawel Rucki <pawel.rucki@roche.com> [aut]
    * Nikolas Burkoff <nikolas.burkoff@roche.com> [aut]
    * Mahmoud Hallal <mahmoud.hallal@roche.com> [aut]
    * Maciej Nasinski <maciej.nasinski@contractors.roche.com> [aut]
    * Konrad Pagacz <konrad.pagacz@contractors.roche.com> [aut]
    * Junlue Zhao <zhaoj88@gene.com> [aut]
    * Chendi Liao <chendi.liao@roche.com> [rev]
    * Dony Unardi <unardid@gene.com> [rev]
    * F. Hoffmann-La Roche AG [cph, fnd]
Description: Introduction of 'qenv' S4 class, that facilitates
    code execution and reproducibility in 'teal' applications.
License: Apache License 2.0
URL: https://insightsengineering.github.io/teal.code/,
    https://github.com/insightsengineering/teal.code
BugReports:
    https://github.com/insightsengineering/teal.code/issues
Depends:
    methods,
    R (>= 4.0)
Imports:
    checkmate (>= 2.1.0),
    grDevices,
    lifecycle (>= 0.2.0),
    rlang (>= 1.1.0)
Suggests:
    cli (>= 3.4.0),
    knitr (>= 1.42),
    magrittr (>= 1.5),
    rmarkdown (>= 2.19),
    shiny (>= 1.6.0),
    testthat (>= 3.1.5)
VignetteBuilder:
    knitr
RdMacros:
    lifecycle
Config/Needs/verdepcheck: mllg/checkmate, r-lib/lifecycle,
    r-lib/rlang, rstudio/shiny, r-lib/styler, r-lib/cli, yihui/knitr,
    tidyverse/magrittr, rstudio/rmarkdown, r-lib/testthat
Config/Needs/website: insightsengineering/nesttemplate
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Collate:
  (...)

@vedhav
Copy link
Contributor Author

vedhav commented Jan 24, 2024

I meant to say teal.slice. My bad.

@gogonzo
Copy link
Contributor

gogonzo commented Jan 24, 2024

Updated the diagram to show the edges with "imports" and "depends", Flipped the direction so it makes sense and Improved the layout.

I still don't find it useful. I think graph doesn't have any value added for the users. It just visually unattractive map of our products. Map doesn't say anything but "these are our products and this is how we complicated relationships between them". What we should do (and did already):

  • we should just explain how to make data for teal and teal.data is the right package
  • how include reporter in teal and that teal.reporter is needed for this
  • etc.

No one except posit cares that dplyr depends on rlang.

@m7pr
Copy link
Contributor

m7pr commented Jan 24, 2024

Hey, sorry for the late input. I also think the diagram is rather more helpful for internal developers and it's not a landing page for end users so I don't think it gives any value for users

@vedhav
Copy link
Contributor Author

vedhav commented Jan 24, 2024

@gogonzo Fair enough. I'll close this PR in that case. The value add (if any) does not justify the addition of new dependencies.

@vedhav vedhav closed this Jan 24, 2024
@vedhav vedhav deleted the dependency-network@main branch January 24, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants