Skip to main content

Python lib for synching with OpenScienceFramework projects

Project description

`pyosf` is a pure Python library for simple file sync with Open Science Framework

This package is for simple synchronisation of files from the local file space to the Open Science Framework (OSF). There is a more complex fully-featured sync package by the Center for Open Science,
who created OSF, called [osf-sync](https://github.com/CenterForOpenScience/osf-sync)

The OSF official package is designed for continuous automated synchronisation of many projects (a la Dropbox). We needed something simpler (for combination with PsychoPy). `pyosf` package aims to perform basic search/login/sync operations with single projects on OSF but only when instructed to do so (no continuous sync).

In implementation `pyosf` differs from osf-sync in the following ways:
* fewer dependencies
* support for Python2.x
* no GUI included (yet)
* local database of files saved as flat json format (no database)
* simpler handling of sync resolution rules(?)

It can be distributed freely under the MIT license.

[![Build Status](https://travis-ci.org/psychopy/pyosf.svg?branch=master)](https://travis-ci.org/psychopy/pyosf)
[![codecov.io](https://codecov.io/github/psychopy/pyosf/coverage.svg?branch=master)](https://codecov.io/github/psychopy/pyosf?branch=master)

Installation
-------------------

`pyosf` is compatible with Linux, OS X and Windows, and with Python 2.7 and Python 3.4 (upwards)

Install it with::

pip install pyosf

Usage
---------

When you first create a `Project`, or to perform searches for projects, you need to create a `Session`::

import pyosf
session = pyosf.Session(username="name@gmail.com", password="xxyxyayxy")

The `Session` allows you to conduct searches::

```python
users = session.find_users("Peirce") # a list of user ids
print users
jon_id = users[0]['id'] # we're just using the first one
projs = session.find_user_projects(user_id=jon_id) # id=None to find your own projects
for proj in projs:
print("{}: {}".format(proj.id, proj.title))

osf_proj = session.open_project(proj_id) # or this if you know the project id
```

Then you can create a `Project` object to track the remote and local files. To do this you need:
- project_file: a location to store project info
- root_path:
- osf: an OSF project object from a `Session`
OR
- simply a project file location, on subsequent repeats

```python
proj = pyosf.Project(project_file="/Home/myUserName/pyosfProjects/first.proj",
root_path="/Home/myUserName/experiments/firstExperiment",
osf=osf_proj)
changes = proj.analyze() #so you can inspect them if needed
changes.apply() #do the sync
proj.save()
```

The project file saves your username (but not password) and, if the username has previously been used to authenticate a `Session` with OSF then an authentication token will have been saved to `~/.pyosf/tokens.json` and that will allow the project to create a new session. i.e. on subseqent logins you can do just

```python
import pyosf
# no need to create a session second time around
proj = pyosf.Project(project_file="/Home/myUserName/pyosfProjects/first.proj")
changes = proj.analyze()
changes.apply()
```

Security and passwords
---------------------------

When you first create a `Session` you need to provide a username (email address) and your OSF password. These will be sent securely (over https) and an auth token will be retrieved. That auth token will be stored in readable text in the current user space of your computer (in ~/.pyosf/tokens.json). When a `Session` is subsequently created the username is used to check for a previous auth token and if one is found a password will not be needed.

The second step is from the `Project`. The `Project` stores in its .proj file (json format) the username that was being used for this sync (as supplied on first access). That username will be used to create a `Session` which will then fetch the appropriate token as described above.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyosf-1.0.5.zip (26.6 kB view details)

Uploaded Source

Built Distribution

pyosf-1.0.5-py2.py3-none-any.whl (26.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pyosf-1.0.5.zip.

File metadata

  • Download URL: pyosf-1.0.5.zip
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyosf-1.0.5.zip
Algorithm Hash digest
SHA256 d45cf885b10403259b37d4f919396db2c86dfd52a022facef63c25ee2e7d5b28
MD5 7c6966ec2bdbb9171b23423bbef53b8e
BLAKE2b-256 fc0316fa680002b9baca7cfe4c6ca17f928094021a43d6f3dda9e7100c7cf0d9

See more details on using hashes here.

File details

Details for the file pyosf-1.0.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pyosf-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ea6ecf89bf9319baf9a5dbd8dd5b0a47982c6701609f813500f00db0b60147d3
MD5 4c1124271c5ed12ef37414a9fb0b4281
BLAKE2b-256 d1fa091aea0dcd05cdc484b33d9556f648af966457882e38733b64a4c3728dd6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page