Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recover_offline error: replace deprecated count() with countDocum… #538

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions fireworks/core/firework.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,20 @@ def _rerun(self) -> None:
a Workflow because a refresh is needed after calling this method.
"""
if self.state == "FIZZLED":
last_launch = self.launches[-1]
if (
EXCEPT_DETAILS_ON_RERUN
and last_launch.action
and last_launch.action.stored_data.get("_exception", {}).get("_details")
):
# add the exception details to the spec
self.spec["_exception_details"] = last_launch.action.stored_data["_exception"]["_details"]
else:
# clean spec from stale details
if len(self.launches) == 0:
self.spec.pop("_exception_details", None)
else:
last_launch = self.launches[-1]
if (
EXCEPT_DETAILS_ON_RERUN
and last_launch.action
and last_launch.action.stored_data.get("_exception", {}).get("_details")
):
# add the exception details to the spec
self.spec["_exception_details"] = last_launch.action.stored_data["_exception"]["_details"]
else:
# clean spec from stale details
self.spec.pop("_exception_details", None)

self.archived_launches.extend(self.launches)
self.archived_launches = list(set(self.archived_launches)) # filter duplicates
Expand Down
3 changes: 2 additions & 1 deletion fireworks/core/launchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,11 @@ def __init__(
raise ValueError("Must specify a database name when using a MongoDB URI string.")
self.db = self.connection[self.name]
else:
if not "socketTimeoutMS" in self.mongoclient_kwargs:
self.mongoclient_kwargs["socketTimeoutMS"] = MONGO_SOCKET_TIMEOUT_MS
self.connection = MongoClient(
self.host,
self.port,
socketTimeoutMS=MONGO_SOCKET_TIMEOUT_MS,
username=self.username,
password=self.password,
authSource=self.authsource,
Expand Down
41 changes: 34 additions & 7 deletions fireworks/flask_site/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ footer .navbar .nav {

.pull-up { margin-bottom: 30px;}

.fw-link {
border-bottom: 1px dotted;
margin-left: 10px;
table {
width: 100%;
table-layout: fixed;
}

.table td{
vertical-align: middle;
.table td {
vertical-align: middle;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 200px;
}


Expand All @@ -34,9 +38,15 @@ footer .navbar .nav {
color: #fff;
}

.fw-link{

.fw-link {
display: inline-block;
max-width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: white;
padding:2px 5px;
padding: 2px 5px;
border-radius: 3px;
box-shadow: 0px 1px 0px #aaa;
}
Expand Down Expand Up @@ -122,3 +132,20 @@ form.query button[type=submit] {
hr.myhrline{
margin:5px;
}

.wf-name strong {
display: inline-block;
max-width: 150px; /* Adjust maximum width as needed */
white-space: nowrap; /* Prevent text from wrapping */
overflow: hidden; /* Hide the overflowed part */
text-overflow: ellipsis; /* Show ellipsis for overflowed text */
vertical-align: bottom;
}

.wf-name {
text-decoration: none; /* Remove underline from the link */
}

.wf-name strong:hover {
cursor: pointer; /* Change cursor to pointer on hover */
}
10 changes: 7 additions & 3 deletions fireworks/flask_site/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,31 @@
<div class="row pull-down">
<div class="span6">
<table class="table table-bordered">
<colgroup>
<col style="width: 100%;">
</colgroup>
<tr><th colspan="3"><a href="/wf">Newest Workflows</a></th></tr>
{% for wf in wf_info %}
<tr>
<td>
<div class="row pull-down-sm">
<div class="span2">
<a href="/wf/{{ wf.id }}"><strong>{{ wf.name }}</strong></a>
<a href="/wf/{{ wf.id }}" class="wf-name" title="{{ wf.name }}">
<strong>{{ wf.name }}</strong>
</a>
</div>
<div class="span3">
<span class="label {{wf.state}}">{{wf.state}}</span>
<span class="pull-right">
ID: <a href="/wf/{{ wf.id }}">{{ wf.id }}</a>
</span>
</div>

</div>
<hr>
<div class="pull-up">
{% for fw in wf.fireworks %}
<div>
<small><a class="fw-link {{fw.state}}" href="/fw/{{ fw.fw_id }}">{{fw.name}}</a></small>
<small><a class="fw-link {{fw.state}}" href="/fw/{{ fw.fw_id }}" title="{{fw.name}}">{{fw.name}}</a></small>
</div>
{% endfor %}
</div>
Expand Down
9 changes: 8 additions & 1 deletion fireworks/scripts/lpad_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ def recover_offline(args: Namespace) -> None:
recovered_fws = []

for launch in lp.offline_runs.find({"completed": False, "deprecated": False}, {"launch_id": 1, "fw_id": 1}):
if fworker_name and lp.launches.count({"launch_id": launch["launch_id"], "fworker.name": fworker_name}) == 0:
if fworker_name and lp.launches.count_documents({"launch_id": launch["launch_id"], "fworker.name": fworker_name}) == 0:
continue
fw = lp.recover_offline(launch["launch_id"], args.ignore_errors, args.print_errors)
if fw:
Expand Down Expand Up @@ -1415,9 +1415,16 @@ def lpad(argv: Sequence[str] | None = None) -> int:
recover_parser.set_defaults(func=recover_offline)

forget_parser = subparsers.add_parser("forget_offline", help="forget offline workflows")
forget_parser.add_argument(*fw_id_args, **fw_id_kwargs)
forget_parser.add_argument("-n", "--name", help="name")
forget_parser.add_argument(*state_args, **state_kwargs)
forget_parser.add_argument(*query_args, **query_kwargs)
forget_parser.add_argument(*launches_mode_args, **launches_mode_kwargs)
forget_parser.add_argument(
"--password",
help="Today's date, e.g. 2012-02-25. Password or positive response to "
f"input prompt required when modifying more than {PW_CHECK_NUM} entries.",
)
forget_parser.set_defaults(func=forget_offline)

# admin commands
Expand Down
2 changes: 1 addition & 1 deletion fireworks/user_objects/queue_adapters/common_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def get_njobs_in_queue(self, username=None):

# run qstat
qstat = Command(self._get_status_cmd(username))
p = qstat.run(timeout=self.timeout, shell=True)
p = qstat.run(timeout=self.timeout)

# parse the result
if p[0] == 0:
Expand Down