{"id":27650299,"url":"https://github.com/futureverse/marshal","last_synced_at":"2025-09-01T10:03:56.441Z","repository":{"id":40374397,"uuid":"333964461","full_name":"futureverse/marshal","owner":"futureverse","description":"[PROTOTYPE] R package: marshal - Framework to Marshal Objects to be Used in Another R Processes","archived":false,"fork":false,"pushed_at":"2025-04-19T17:09:52.000Z","size":1963,"stargazers_count":14,"open_issues_count":9,"forks_count":1,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2025-04-24T03:36:57.729Z","etag":null,"topics":["marshalling","package","parallel","r","serialization"],"latest_commit_sha":null,"homepage":"https://marshal.futureverse.org/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/futureverse.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-01-28T21:45:22.000Z","updated_at":"2024-10-20T17:09:36.000Z","dependencies_parsed_at":"2023-10-04T08:16:58.572Z","dependency_job_id":"24ca3611-9047-4b78-8694-190b1e6c0426","html_url":"https://github.com/futureverse/marshal","commit_stats":null,"previous_names":["futureverse/marshal","henrikbengtsson/marshal"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/futureverse/marshal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futureverse%2Fmarshal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futureverse%2Fmarshal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futureverse%2Fmarshal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futureverse%2Fmarshal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/futureverse","download_url":"https://codeload.github.com/futureverse/marshal/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futureverse%2Fmarshal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273105948,"owners_count":25046950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["marshalling","package","parallel","r","serialization"],"created_at":"2025-04-24T03:34:21.781Z","updated_at":"2025-09-01T10:03:56.428Z","avatar_url":"https://github.com/futureverse.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv id=\"badges\"\u003e\u003c!-- pkgdown markup --\u003e\n\u003ca href=\"https://github.com/futureverse/marshal/actions/workflows/R-CMD-check.yaml\"\u003e\u003cimg src=\"https://github.com/futureverse/marshal/actions/workflows/R-CMD-check.yaml/badge.svg\" alt=\"R-CMD-check\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://henrikbengtsson.r-universe.dev/marshal\"\u003e\u003cimg src=\"https://henrikbengtsson.r-universe.dev/badges/marshal\" alt=\"port4me status badge\"/\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n# marshal: Unified API for Marshalling R Objects\n\n## News\n\n* May 2024: We have launched the R Consortium ISC Working Group\n  ['Marshaling and Serialization in\n  R'](https://github.com/RConsortium/marshalling-wg) to work on this\n  problem.\n\n\n## Introduction\n\nSome types of R objects can be used only in the R session they were\ncreated.  If used as-is in another R process, such objects often\nresult in an immediate error or in obscure and hard-to-troubleshoot\noutcomes.  Because of this, they cannot be saved to file and re-used\nat a later time.  They may also not be exported to a parallel worker\nwhen doing parallel processing.  These objects are sometimes referred\nto as non-exportable or non-serializable objects.  For example, assume\nwe load an HTML document using the **xml2** package:\n\n```r\nfile \u003c- system.file(\"extdata\", \"r-project.html\", package = \"xml2\")\ndoc \u003c- xml2::read_html(file)\n```\n\nNext, imagine that we would save this document object `doc` to file\nand quit R;\n\n```r\nsaveRDS(doc, \"html.rds\")\nquit()\n```\n\nThen, if we try to use this saved **xml2** object in another R\nsession, we'll find that it will not work;\n\n```r\ndoc2 \u003c- readRDS(\"html.rds\")\nxml2::xml_length(doc2)\n#\u003e Error in xml_length.xml_node(doc2) : external pointer is not valid\n```\n\nThis is because **xml2** objects only work in the R process that\ncreated them.\n\nOne solution to this problem is to use \"marshalling\" to encode the R\nobject into an exportable representation that then can be used to\nre-create a copy of that object in another R process that imitates the\noriginal object.\n\nThe **marshal** package provides generic functions `marshal()` and\n`unmarshal()` for marshalling and unmarshalling R objects of certain\nclass.  This makes it possible to save otherwise non-exportable\nobjects to file and then be used in a future R session, or to transfer\nthem to another R process to be used there.\n\n\n## Proposed API\n\nThe long-term goal with this package is for it to provide a de-facto\nstandard and API for marshalling and unmarshalling objects in R.  To\nachieve this, this package proposes three generic functions:\n\n 1. `marshallable()` - check whether an R object can be marshalled or\n    not\n \n 2. `marshal()` - marshal an R object\n \n 3. `unmarshal()` - reconstruct a marshalled R object\n\n\nIf we return to our **xml2** object, the **marshal** package\nimplements an S3 `marhal()` method for different **xml2** classes that\ntakes care of everything for us.  We can use this when we save the\nobject;\n\n```r\nfile \u003c- system.file(\"extdata\", \"r-project.html\", package = \"xml2\")\ndoc \u003c- xml2::read_html(file)\n\nsaveRDS(marshal::marshal(doc), \"html.rds\")\n\nquit()\n```\n\nLater, in another R session, we can reconstruct this **xml2** HTML\ndocument by using:\n\n```sh\ndoc2 \u003c- marshal::unmarshal(readRDS(\"html.rds\"))\nxml2::xml_length(doc2)\n[1] 2\n```\n    \n\n## Currently supported packages\n\nIn order to test the proposed solution and API, this package will\nimplement S3 `marshal()` methods for some common R packages and their\nnon-exportable classes.  Note that the long-term goals is that these\nS3 methods should be implemented by these packages themselves, such\nthat the **marshal** package will only provide a light-weight API.\n\nThe [A Future for R: Non-Exportable Objects] vignette has a collection\nof packages and classes that cannot be exported out of the box.  This\npackage has marshalling prototypes for objects from the following\npackages:\n\n* **caret**\n* **data.table**\n* **keras**\n* **ncdf4**\n* **parsnip**\n* **raster**\n* **rstan**\n* **terra**\n* **xgboost**\n* **XML**\n* **xml2**\n\nIt also has implementations that will throw an error for objects from\nthe following packages, because they cannot be marshalled, at least\nnot at the moment:\n\n* **DBI**\n* **magick**\n* **parallel**\n\nThe plan is to improve on add support for more R packages and object\nclasses.\n\n\n## Installation\n\nThe **marshal** package is not, yet, on CRAN.  In the meanwhile, it\ncan be installed from the R Universe as:\n\n```r\noptions(repos = c(\"https://futureverse.r-universe.dev\", getOption(\"repos\")))\ninstall.packages(\"marshal\")\n```\n\n\n### Pre-release version\n\nTo install the pre-release version that is available in Git branch\n`develop` on GitHub, use:\n\n```r\nremotes::install_github(\"futureverse/marshal\", ref = \"develop\")\n```\n\nThis will install the package from source.\n\n\u003c!-- pkgdown-drop-below --\u003e\n\n\n[A Future for R: Non-Exportable Objects]: https://cran.r-project.org/package=future/vignettes/future-4-non-exportable-objects.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffutureverse%2Fmarshal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffutureverse%2Fmarshal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffutureverse%2Fmarshal/lists"}