Skip to content

Commit

Permalink
updates with new tests. not finished
Browse files Browse the repository at this point in the history
  • Loading branch information
dsschult committed Jan 3, 2024
1 parent 08e2abb commit b0b0871
Show file tree
Hide file tree
Showing 16 changed files with 2,047 additions and 2,118 deletions.
12 changes: 2 additions & 10 deletions bin/iceprod_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@
from iceprod.server.server import Server


# start server
async def start_server(*args, **kwargs):
s = Server(*args, **kwargs)
await s.start()
try:
await asyncio.Event().wait()
finally:
await s.stop()

def runner(stdout=False, *args, **kwargs):
# set logger
if stdout:
Expand All @@ -47,7 +38,8 @@ def runner(stdout=False, *args, **kwargs):
except Exception:
logging.warning("could not rename process")

asyncio.run(start_server(*args, **kwargs))
s = Server(*args, **kwargs)
asyncio.run(s.run())
logging.warning('iceprod exiting')

def setup_I3PROD():
Expand Down
160 changes: 0 additions & 160 deletions bin/loader.sh

This file was deleted.

2 changes: 1 addition & 1 deletion iceprod/rest/handlers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ async def post(self):
print('filter_query', filter_query)
ret = await self.db.tasks.find_one_and_update(
filter_query,
{'$set': {'status': 'queued'}},
{'$set': {'status': 'queued', 'site': site}},
projection={'_id': False},
sort=sort_by,
return_document=pymongo.ReturnDocument.AFTER
Expand Down
8 changes: 5 additions & 3 deletions iceprod/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ class IceProdConfig(dict):
defaults: use default values (optional: default True)
validate: turn validation on/off (optional: default True)
override: override list of key=value strings
save: enable saving to file (optional: default True)
"""
def __init__(self, filename=None, defaults=True, validate=True, override=None):
def __init__(self, filename=None, defaults=True, validate=True, override=None, save=True):
if filename:
self.filename = filename
else:
self.filename = os.path.expandvars('$I3PROD/etc/iceprod_config.json')

if not Path(self.filename).parent.is_dir():
if save and not Path(self.filename).parent.is_dir():
raise RuntimeError('$I3PROD/etc does not exist')

self.validate = validate
self._save = save
self.loading = False

# load user input, apply defaults, and save
Expand Down Expand Up @@ -168,7 +170,7 @@ def save_to_string(self):

def save(self):
"""Save config from file."""
if not self.loading:
if self._save and not self.loading:
try:
# save securely
with os.fdopen(os.open(self.filename+'.tmp', os.O_WRONLY | os.O_CREAT, 0o600), 'w') as f:
Expand Down
21 changes: 21 additions & 0 deletions iceprod/server/data/condor_input_precmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3

import os
from pathlib import Path
import sys


"""
This is a PreCmd script designed to rewrite input file names.
"""

for arg in sys.argv[1:]:
try:
name, newname = arg.split('=',1)
if '/' in newname:
newname = Path(newname)
newname.parent.mkdir(parents=True, exists_ok=True)
os.rename(name, newname)
except Exception:
print(f'Cannot move inputfile {name} to {newname}', file=sys.stderr)
raise
Loading

0 comments on commit b0b0871

Please sign in to comment.