Skip to content

Commit

Permalink
Merge branch 'development' into feature/jupyter_compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
lej0hn authored Jul 5, 2024
2 parents bb8f3de + 81abeea commit ba5a385
Show file tree
Hide file tree
Showing 7 changed files with 448 additions and 14 deletions.
8 changes: 8 additions & 0 deletions docs/source/pyneuroml.swc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ pyneuroml.swc package
:undoc-members:
:show-inheritance:

pyneuroml.swc.LoadSWC module
------------------------------

.. automodule:: pyneuroml.swc.LoadSWC
:members:
:undoc-members:
:show-inheritance:

pyneuroml.swc.ExportSWC module
------------------------------

Expand Down
38 changes: 29 additions & 9 deletions pyneuroml/biosimulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def submit_simulation_archive(
archive_file: str,
sim_dict: typing.Dict[str, typing.Union[int, str, typing.List[str]]] = {},
dry_run: bool = False,
) -> object:
) -> typing.Dict[str, typing.Union[str, object]]:
"""Submit an OMEX archive to biosimulations using the provided simulation run dictionary
.. versionadded:: 1.2.10
Expand Down Expand Up @@ -203,7 +203,12 @@ def submit_simulation_archive(
https://api.biosimulations.org/#/Simulations/SimulationRunController_createRun
:type sim_dict: dict
:returns: the requests.post response object, or True if dry_run
:returns: dictionary with keys "response", "download", "logs", "view" that
contain the response object and download, logs, and view URLs
If a dry run, response is True and the URLs are all None
:rtype: dict
"""
api_url = f"{biosimulations_api_url}/runs"
Expand All @@ -230,6 +235,8 @@ def submit_simulation_archive(
logger.info(f"multipart encoded data is {m}")
logger.info(f"with content type: {m.content_type}")

resdict = {}

if dry_run is False:
logger.info("Submitting archive to biosimulations")
response = requests.post(
Expand All @@ -242,16 +249,29 @@ def submit_simulation_archive(
print(
f"Submitted {archive_file} successfully with id: {serv_response['id']}"
)
print(f"View: {biosimulations_api_url}/runs/{serv_response['id']}")
print(
f"Downloads: {biosimulations_api_url}/results/{serv_response['id']}/download"
)
print(
f"Logs: {biosimulations_api_url}/logs/{serv_response['id']}?includeOutput=true"

log_url = f"{biosimulations_api_url}/logs/{serv_response['id']}?includeOutput=true"
view_url = f"{biosimulations_api_url}/runs/{serv_response['id']}"
download_url = (
f'{biosimulations_api_url}/results/{serv_response["id"]}/download'
)

print(f"View: {view_url}")
print(f"Downloads: {download_url}")
print(f"Logs: {log_url}")

resdict["response"] = response
resdict["view"] = view_url
resdict["download"] = download_url
resdict["logs"] = log_url
else:
response = True
print("Dry run, not submitting")
print(f"Simulation dictionary: {sim_dict}")

return response
resdict["response"] = response
resdict["view"] = None
resdict["download"] = None
resdict["logs"] = None

return resdict
9 changes: 5 additions & 4 deletions pyneuroml/swc/ExportSWC.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""
A script to export SWC files from NeuroML <cell>s
A script to export SWC files from NeuroML <cell>s
"""

import logging
import os
import sys
import logging
from pyneuroml import pynml

from pyneuroml import __version__ as pynmlv
from pyneuroml.io import read_neuroml2_file

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -117,7 +118,7 @@ def convert_to_swc(nml_file_name, add_comments=False, target_dir=None):
if target_dir is None:
base_dir = os.path.dirname(os.path.realpath(nml_file_name))
target_dir = base_dir
nml_doc = pynml.read_neuroml2_file(
nml_doc = read_neuroml2_file(
nml_file_name, include_includes=True, verbose=False, optimized=True
)

Expand Down
Loading

0 comments on commit ba5a385

Please sign in to comment.