Skip to content

Commit

Permalink
Restrict micromamba version < 2.0 (#201)
Browse files Browse the repository at this point in the history
* directly download fixed micromamba version

* Update test_service.py

* Update service.py

---------

Co-authored-by: Volodymyr <[email protected]>
  • Loading branch information
dsavchenko and volodymyrss authored Oct 16, 2024
1 parent d1f1772 commit ad02f1a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
28 changes: 20 additions & 8 deletions nb2workflow/galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from textwrap import dedent
import argparse
import logging
import requests

import yaml
import json
Expand All @@ -16,7 +17,6 @@
import nbformat
from nbconvert.exporters import ScriptExporter

from ensureconda.api import ensureconda
import subprocess as sp

import bibtexparser as bib
Expand Down Expand Up @@ -476,13 +476,25 @@ def _parse_requirements_txt(filepath):
return reqs_str_list

@staticmethod
def _get_micromamba_binary():
mamba_bin = ensureconda(no_install=False,
micromamba=True,
mamba=False,
conda=False,
conda_exe=False)
return mamba_bin
def _get_micromamba_binary():
micromamba_dir = os.path.join(
os.environ.get('HOME', os.getcwd()),
'.local',
'bin'
)
os.makedirs(micromamba_dir, exist_ok=True)
mambapath = os.path.join(micromamba_dir, 'micromamba')

if not os.path.isfile(mambapath):
release_url="https://github.com/mamba-org/micromamba-releases/releases/download/1.5.10-0/micromamba-linux-64"
res = requests.get(release_url, allow_redirects=True)
with open(mambapath, 'wb') as fd:
fd.write(res.content)

if not os.access(mambapath, os.X_OK):
os.chmod(mambapath, 0o744)

return mambapath

def _split_bibfile(filepath):
# parse bibfile and return only entries (no preamble/comments/strings) as list of strings
Expand Down
3 changes: 2 additions & 1 deletion nb2workflow/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import tempfile
import nbformat
import yaml
import traceback

from io import BytesIO
from bs4 import BeautifulSoup
Expand Down Expand Up @@ -153,7 +154,7 @@ def run(self):
try:
self._run()
except Exception as e:
logger.error("run failed unexplicably: %s", repr(e))
logger.error("run failed inexplicably: %s\n%s", repr(e), traceback.format_exc())
app.async_workflows[self.key] = dict(
output={},
exceptions=[serialize_workflow_exception(e)]
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
'Jinja2'
],
'galaxy':[
'ensureconda',
'bibtexparser >= 2.0.0b3',
'pypandoc_binary',
'black',
Expand Down
4 changes: 3 additions & 1 deletion tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,7 @@ def test_worker_run():

test_worker_thread.join()

logger.info("output has keys: %s", list(r.json['data']['output']))

open("output.png","wb").write(base64.b64decode(r.json['data']['output']['spectrum_png_content']))


0 comments on commit ad02f1a

Please sign in to comment.