Skip to content

Commit

Permalink
allow for instantiation of FluxBurst when handle is not ready (#10)
Browse files Browse the repository at this point in the history
* allow for instantiation of FluxBurst when handle is not ready

we want to be able to possibly control creating the first
instance (e.g., local slurm mock) and the handle may not
be ready yet.

Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch committed Jul 15, 2023
1 parent 0022025 commit 6a2ca60
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pre-commit
black
black==23.3.0
isort
flake8
pytest
14 changes: 13 additions & 1 deletion fluxburst/handles.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,21 @@ def get_job_info(self, jobid):

class FluxHandle:
def __init__(self, handle=None):
self._handle = handle

@property
def handle(self):
"""
A handle propery to "handle" connection! har har.
We import Flux here to allow instantiating the client possibly
after the instance is created.
"""
import flux

self.handle = handle or flux.Flux()
if not self._handle:
self._handle = flux.Flux()
return self._handle

def update_jobspec(self, job):
"""
Expand Down
2 changes: 1 addition & 1 deletion fluxburst/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
write_json,
write_yaml,
)
from .misc import choose, chunks, get_hash, mb_to_bytes, print_bytes, slugify
from .misc import chunks, get_hash, mb_to_bytes, print_bytes, slugify
from .terminal import (
check_install,
confirm_action,
Expand Down
9 changes: 0 additions & 9 deletions fluxburst/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import copy

from pick import pick


def chunks(listing, chunk_size):
"""
Expand Down Expand Up @@ -43,13 +41,6 @@ def mb_to_bytes(mb):
return mb * (1048576)


def choose(options, prompt, default_index=0):
"""
Use pick to choose one of a few options, return the chosen option.
"""
return pick(options, prompt, indicator="=>", default_index=default_index)


def get_hash(obj):
"""
Get a hash for a random object (set, tuple, list, dict)
Expand Down
1 change: 0 additions & 1 deletion fluxburst/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
("rich", {"min_version": None}),
("oras", {"min_version": None}),
("requests", {"min_version": None}),
("pick", {"min_version": None}),
)

INSTALL_REQUIRES_KUBERNETES = (
Expand Down

0 comments on commit 6a2ca60

Please sign in to comment.