Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ Both of these dependencies can be installed via `pip` using
sudo pip install -r requirements.txt
```

Alternatively, users can install Git-RDM and its dependencies with [Conda](http://conda.pydata.org/); see the details in the next section.

Note that once PyRDM is installed, you will need to setup Figshare/Zenodo authentication tokens and copy them into the PyRDM configuration file in order to publish your data. See the [PyRDM documentation](https://pyrdm.readthedocs.io/en/latest/getting_started.html) for instructions on how to do this.

## Installing

Git-RDM can either be installed from source, or via Conda packages; see the appropriate sub-section for more details. Once Git-RDM is installed, Git should automatically detect the plugin and recognise the `rdm` command; for example, run `git rdm -h` to list the RDM-related subcommands described in the Usage section below.

### From source

After downloading or cloning this software using

```
Expand All @@ -39,7 +45,25 @@ and running
sudo python setup.py install
```

Once Git-RDM is installed, Git should automatically detect the plugin and recognise the `rdm` command; for example, run `git rdm -h` to list the RDM-related subcommands described in the Usage section below.
Alternatively, a local user installation can be achieved using

```
python setup.py install --prefix=/path/to/custom/install/directory
```

and adding `/path/to/custom/install/directory/bin` to the `PATH` environment variable:

```
export PATH=$PATH:/path/to/custom/install/directory/bin
```

### Conda package

Conda users can install the Git-RDM package and its dependencies using

```
conda install -c ctjacobs -c pypi -c auto -c ioos -c conda-forge git-rdm
```

## Usage

Expand Down Expand Up @@ -139,6 +163,17 @@ git-rdm INFO: /home/christian/test/test3.png (2016-06-13 @ 00:29:03, revision
git-rdm INFO: /home/christian/test/test2.txt (2016-06-13 @ 00:29:03, revision '1eeccabba810b8c91eef82e692713fdb05ca4a32')
```

To check the raw, unformatted contents of the entire publications database, use the `--raw` flag:

```
~/test $ git rdm ls --raw
git-rdm INFO: Database dump:
git-rdm INFO: id, path, date, time, sha, pid, doi
git-rdm INFO: 13, /home/christian/test/test1.txt, 2016-06-13, 00:29:03.016951, 1eeccabba810b8c91eef82e692713fdb05ca4a32, 3428222, 10.6084/m9.figshare.3428222
git-rdm INFO: 14, /home/christian/test/test3.png, 2016-06-13, 00:29:03.016951, 1eeccabba810b8c91eef82e692713fdb05ca4a32, 3428222, 10.6084/m9.figshare.3428222
git-rdm INFO: 15, /home/christian/test/test2.txt, 2016-06-13, 00:29:03.016951, 1eeccabba810b8c91eef82e692713fdb05ca4a32, 3428222, 10.6084/m9.figshare.3428222
```

### git rdm show

The full publication record maintained by the data repository service can be shown using `git rdm show`. It expects two arguments: the name of the hosting service (`figshare` or `zenodo`) and the publication ID. For example, for the publication whose Figshare publication ID is 3428222 (and DOI is `10.6084/m9.figshare.3428222`), the (truncated) output is:
Expand Down Expand Up @@ -177,6 +212,12 @@ git-rdm INFO: {
## License
This software is released under the MIT license. See the file called `LICENSE` for more information.

## Citing

If you use Git-RDM during the course of your research, please consider citing the following paper:

* C. T. Jacobs, A. Avdis (Under Review). Git-RDM: A research data management plugin for the Git version control system. *Journal of Open Source Software*.

## Contact
Please send any questions or comments about Git-RDM via email to [Christian Jacobs](http://christianjacobs.uk) at <christian@christianjacobs.uk>.

Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"keywords": "research data management, git, version control, digital curation, data, publishing, figshare, zenodo",
"license": "MIT",
"title": "Git-RDM",
"version": "v1.0.0"
}
"version": "v1.0.1"
}
36 changes: 30 additions & 6 deletions git-rdm
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,38 @@ class GitRDM:

return

def ls(self, path=None, by_doi=True):
def ls(self, path=None, by_doi=True, raw=False):
""" List all published files, and files to be published. If a file has multiple DOIs associated with it then they are all listed together.

:arg path: The relative/absolute path to the file to be listed.
:arg bool by_doi: List the files by DOI first (i.e. each DOI will be listed at the top level, with names of the files associated with that DOI underneath).
:arg bool raw: Print out the entire SQL database table without any formatting.
"""

self.db_connect()


self.db_connect()

# Raw database dump of all the rows
if raw:
_LOG.info("Database dump:")

query = "SELECT * FROM %s" % PUBLICATIONS_TABLE

with self.connection:
c = self.connection.cursor()
c.execute(query)
result = c.fetchall()
if len(result) > 0:
# Column names
names = list(map(lambda x: x[0], c.description))
_LOG.info(", ".join(names))

# Rows
for r in result:
values = [str(r[name]) for name in names]
_LOG.info(", ".join(values))

return

# If a path is provided, then specify all the publications/DOIs associated with that path.
if path:
path = os.path.abspath(path) # Get the absolute path
Expand All @@ -194,7 +217,7 @@ class GitRDM:
for r in result:
_LOG.info("\t" + str(r["doi"]) + " (" + str(r["date"]) + " @ " + str(r["time"]).split(".")[0] + ", revision '%s')" % r["sha"])
return

# List all published files.
if by_doi:
query = "SELECT * FROM %s WHERE doi IS NOT NULL ORDER BY doi" % PUBLICATIONS_TABLE
Expand Down Expand Up @@ -483,6 +506,7 @@ if(__name__ == "__main__"):
ls_parser = subparsers.add_parser("ls", help="List the published files, and files staged for publishing.")
ls_parser.add_argument("--path", required=False, help="The path to the file to list.", action="store", type=str, default=None)
ls_parser.add_argument("--by-doi", help="Group files by DOI.", action="store_true", default=False, dest="by_doi")
ls_parser.add_argument("--raw", help="Print out the entire SQL database table without any formatting.", action="store_true", default=False, dest="raw")

# 'git rdm publish'
publish_parser = subparsers.add_parser("publish", help="Publish the files in the publishing staging area.")
Expand Down Expand Up @@ -511,7 +535,7 @@ if(__name__ == "__main__"):
elif args.subcommand == "rm":
rdm.rm(args.path)
elif args.subcommand == "ls":
rdm.ls(path=args.path, by_doi=args.by_doi)
rdm.ls(path=args.path, by_doi=args.by_doi, raw=args.raw)
elif args.subcommand == "publish":
rdm.publish(service=args.service, pid=args.pid)
elif args.subcommand == "show":
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from distutils.core import setup

setup(name='git-rdm',
version='1.0',
version='1.0.1',
description='Git-RDM is a research data management plugin for the Git version control system.',
author='Christian T. Jacobs, Alexandros Avdis',
author_email='christian@christianjacobs.uk',
Expand Down