Skip to content

Commit

Permalink
Merge remote-tracking branch 'uliege/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
urubens committed Feb 1, 2021
2 parents 601c2ea + dd11318 commit 98428e1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,28 @@ See [documentation](http://doc.cytomine.be/display/ALGODOC/%5BDOC%5D+Data+access

**To install *official* release of Cytomine-python-client, see @cytomine. Follow this guide to install forked version by ULiege.**

### Manual installation
To download and install manually the package, see [manual installation procedure](http://doc.cytomine.be/display/ALGODOC/Data+access+using+Python+client#DataaccessusingPythonclient-Installation).

### Automatic installation
To retrieve package using `pip`:

pip install --extra-index-url=https://packagecloud.io/cytomine-uliege/Cytomine-python-client/pypi/simple cytomine-python-client

or, to add the extra index permanently to your `pip` configuration:

curl -s https://packagecloud.io/install/repositories/cytomine-uliege/Cytomine-python-client/script.python.sh | bash
pip install cytomine-python-client

See [package repository](https://packagecloud.io/cytomine-uliege/Cytomine-python-client) for details.

### Manual installation
To download and install manually the package in a Python env, run (here for version 2.7.3):

wget https://github.com/Cytomine-ULiege/Cytomine-python-client/releases/download/v2.7.3/Cytomine-Python-Client-2.7.3.zip
unzip Cytomine-Python-Client-2.7.3.zip
cd Cytomine-Python-Client-2.7.3
pip install .

For more details and manual installation with Miniconda, see [manual installation procedure](http://doc.cytomine.be/display/ALGODOC/Data+access+using+Python+client#DataaccessusingPythonclient-Installation).

### In a Docker container
To ease developpement of new Cytomine software, the Cytomine-python-client package is available in Docker containers:
* [cytomineuliege/software-python3-base](https://hub.docker.com/r/cytomineuliege/software-python3-base/) provides a Python 3.5 environment with client already installed.
Expand Down Expand Up @@ -84,4 +95,4 @@ When using our software, we kindly ask you to cite our website url and related p

## License

Apache 2.0
Apache 2.0
25 changes: 19 additions & 6 deletions cytomine/utilities/descriptor_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@
__author__ = "Rubens Ulysse <urubens@uliege.be>"


def read_descriptor(filename, schema_version="cytomine-0.1"):
def _format_type(type):
if type.lower() == "listdomain":
return "ListDomain"
else:
return type.lower().capitalize()


def read_descriptor(filename, schema_version="cytomine-0.1", delete_missing=False):
"""
Read a software descriptor and add a not executable version of it to Cytomine.
It should be used only for software development or testing purpose.
Expand All @@ -45,6 +52,8 @@ def read_descriptor(filename, schema_version="cytomine-0.1"):
The descriptor file path.
schema_version: String
The version of descriptor schema.
delete_missing: Bool
If set to True, deletes the registered parameters missing from the descriptor file.
Returns
-------
Expand All @@ -66,6 +75,7 @@ def read_descriptor(filename, schema_version="cytomine-0.1"):
software = existing_software[0]

existing_software_parameters = SoftwareParameterCollection().fetch_with_filter("software", software.id)
processed_parameters = set()

for parameter_descriptor in descriptor["inputs"]:
if "id" not in parameter_descriptor.keys():
Expand All @@ -87,13 +97,9 @@ def read_descriptor(filename, schema_version="cytomine-0.1"):
.replace("@id", parameter_descriptor["id"].lower()) if isinstance(v, str) else v
for k, v in parameter_descriptor.items()}

type = param["type"].lower().capitalize()
if type == 'Listdomain':
type = 'ListDomain'

sp = SoftwareParameter(
name=param["id"],
type=type,
type=_format_type(param["type"]),
id_software=software.id,
default_value=(param["default-value"] if "default-value" in param.keys() else ""),
required=(not param["optional"] if "optional" in param.keys() else False),
Expand All @@ -113,6 +119,13 @@ def read_descriptor(filename, schema_version="cytomine-0.1"):
else:
sp.update(existing_software_parameter[0].id)

processed_parameters.add(param["id"])

if delete_missing:
for parameter in existing_software_parameters:
if parameter.name not in processed_parameters:
parameter.delete()

return software


Expand Down

0 comments on commit 98428e1

Please sign in to comment.