Skip to content

Commit

Permalink
Merge pull request #349 from genestack/master
Browse files Browse the repository at this point in the history
Merge master to the stable for the release
  • Loading branch information
nzorkic-genestack committed Nov 16, 2022
2 parents a888c4b + a943165 commit 733cdfc
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 53 deletions.
5 changes: 4 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* 0.35.0
* Genestack host is now mandatory when setting up the Genestack user, default host has been removed

* 0.34.0
* Initial Python 3 support
* Implement auto checking for common sub-URLs (no explicit `/frontend`
Expand All @@ -9,7 +12,7 @@
* `normalised_input` argument for ExpressionNavigator applications
* `Connection.open` method
* `CLApplication.rename_file` method
* `DataImporter.create_owl_ontology` method
* `DataImporter`: `create_owl_ontology` and `create_pathway_database` methods
* `FilesUtil`: `create_dataset`, `get_groups_to_share`, `share_files`,
`share_folder` methods
* `TaskLogViewer.view_log` method
Expand Down
36 changes: 0 additions & 36 deletions genestack_client/data_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,39 +740,3 @@ def create_microarray_annotation(self, annotation_type, parent=None,
self.__add_to_metainfo(metainfo, Metainfo.NAME, name, StringValue, required=True)
self.__add_to_metainfo(metainfo, BioMetaKeys.DATA_LINK, url, ExternalLink, required=True)
return self.__invoke_loader(parent, annotation_type, metainfo)

def create_pathway_database(
self, db_name=None, version=None, parent=None, url=None, name=None, metainfo=None
):
"""
Create a Pathway Database file from a local or remote BioPAX archive.
``name`` and ``url` are required fields.
They can be specified through the arguments or
via a :py:class:`~genestack_client.Metainfo` instance.
:param db_name: pathway database name (e.g. 'Reactome')
:type db_name: str
:param version: pathway database version (e.g. 'v50')
:type version: str
:param parent: accession of parent folder
(if not provided, files will be created in the ``Imported files`` folder)
:type parent: str
:param url: URL of a BioPAX archive
:type url: str
:param name: name of the created Genestack file
:type name: str
:param metainfo: metainfo of the created Genestack file
:type metainfo: Metainfo
:return: file accession
:rtype: str
"""
metainfo = DataImporter._copy_metainfo(metainfo)
self.__add_to_metainfo(metainfo, Metainfo.NAME, name, StringValue, required=True)
self.__add_to_metainfo(metainfo, BioMetaKeys.DATA_LINK, url, ExternalLink, required=True)
self.__add_to_metainfo(
metainfo, 'genestack.bio:pathwayDatabaseName', db_name, StringValue, required=True
)
self.__add_to_metainfo(
metainfo, 'genestack.bio:pathwayDatabaseVersion', version, StringValue, required=True
)
return self.__invoke_loader(parent, 'pathwayDatabase', metainfo)
24 changes: 17 additions & 7 deletions genestack_client/scripts/genestack_user_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from __future__ import unicode_literals

from future import standard_library

standard_library.install_aliases()
from builtins import input
from builtins import *
Expand All @@ -19,13 +20,18 @@

from genestack_client import GenestackAuthenticationException
from genestack_client.genestack_shell import Command, GenestackShell
from genestack_client.settings import DEFAULT_HOST, User, config
from genestack_client.settings import User, config
from genestack_client.utils import interactive_select


def input_host():
host = input('host [%s]: ' % DEFAULT_HOST).strip()
return host or DEFAULT_HOST
print('Please input Genestack host address')
while True:
host = input('host: ').strip()
if not host:
print('Host can not be empty')
continue
return host


def validate_alias(alias):
Expand Down Expand Up @@ -335,9 +341,8 @@ def get_command_parser(self, parser=None):
parser.description = self.DESCRIPTION
group = parser.add_argument_group('command arguments')
self.update_parser(group)
group.add_argument('-H', '--host', default=DEFAULT_HOST,
help='Genestack host, '
'change it to connect somewhere else than %s' % DEFAULT_HOST,
group.add_argument('-H', '--host',
help='Genestack host address',
metavar='<host>')
return parser

Expand Down Expand Up @@ -388,16 +393,21 @@ class UserManagement(GenestackShell):
prompt = 'user_setup> '

def set_shell_user(self, args):
if not args.host:
sys.stderr.write("Genestack host is mandatory. Please specify the host using the -H flag")
sys.exit(1)

config_path = config.get_settings_file()
if not os.path.exists(config_path):
print('No config file was found, creating one interactively')
self.process_command(Init(), ['--host', args.host or DEFAULT_HOST], False)
self.process_command(Init(), ['--host', args.host], False)
args.host = None # do not provide host for future use of arguments


def main():
shell = UserManagement()
shell.cmdloop()


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion genestack_client/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
standard_library.install_aliases()
from builtins import *
from genestack_client.settings.genestack_config import config
from genestack_client.settings.genestack_user import DEFAULT_HOST, User
from genestack_client.settings.genestack_user import User


7 changes: 2 additions & 5 deletions genestack_client/settings/genestack_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import unicode_literals

from future import standard_library

standard_library.install_aliases()
from builtins import input
from builtins import *
Expand All @@ -18,8 +19,6 @@
from genestack_client import Connection, GenestackAuthenticationException, GenestackException
from genestack_client.utils import isatty, interactive_select

DEFAULT_HOST = 'platform.genestack.org'


def _get_server_url(host):
split_host = urlsplit(host)
Expand Down Expand Up @@ -62,7 +61,6 @@ def __init__(self, email, alias=None, host=None, password=None, token=None):
"""
All fields are optional.
If ``alias`` is None it will be the same as ``email``.
If no ``host`` is specified, the ``DEFAULT_HOST`` be used.
If you login interactively, no ``email`` or ``password`` is required.
The alias is used to find the matching user in :py:func:`~genestack_client.get_user`
Expand All @@ -76,7 +74,7 @@ def __init__(self, email, alias=None, host=None, password=None, token=None):
:param password: password
:type password: str
"""
self.host = host or DEFAULT_HOST
self.host = host
self.email = email
self.password = password # TODO make property
self.alias = alias or email
Expand All @@ -87,7 +85,6 @@ def get_connection(self, interactive=True, debug=False, show_logs=False):
Return a logged-in connection for current user.
If ``interactive`` is ``True`` and the password or email are unknown,
they will be asked in interactive mode.
If no host is specified, the ``DEFAULT_HOST`` will be used.
:param interactive: ask email and/or password interactively.
:type interactive: bool
Expand Down
2 changes: 1 addition & 1 deletion genestack_client/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.34.0'
__version__ = '0.35.0'
3 changes: 1 addition & 2 deletions test/test_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from genestack_client import get_user, make_connection_parser
from genestack_client.settings.genestack_user import User, DEFAULT_HOST
from genestack_client.settings.genestack_user import User


def test_parse_default_user():
Expand Down Expand Up @@ -100,7 +100,6 @@ def test_token_without_username():
args = parser.parse_args(['--token', some_token])
user = get_user(args)
assert user.token == some_token
assert user.host == DEFAULT_HOST


if __name__ == '__main__':
Expand Down

0 comments on commit 733cdfc

Please sign in to comment.