More work on improving docs.
authorScott Gasch <[email protected]>
Thu, 13 Oct 2022 19:14:13 +0000 (12:14 -0700)
committerScott Gasch <[email protected]>
Thu, 13 Oct 2022 19:14:13 +0000 (12:14 -0700)
examples/parallelize_config/.remote_worker_records [new file with mode: 0644]
src/pyutils/collectionz/shared_dict.py
src/pyutils/datetimez/datetime_utils.py
src/pyutils/string_utils.py

diff --git a/examples/parallelize_config/.remote_worker_records b/examples/parallelize_config/.remote_worker_records
new file mode 100644 (file)
index 0000000..1a41fbf
--- /dev/null
@@ -0,0 +1,16 @@
+# This file is a record of remote workers that @parallelize(method=Method.REMOTE)
+# may send work to.  Each must have the same version of python installed and the
+# cloudpickle package available.  "username" (see below) must be able to ssh into
+# each machine non-interactively (e.g. with a public/private trusted key, see ssh
+# documentation).  "weight" should be used to indicate the speed of a CPU on the
+# target machine and "count" should be used to indicate how many parallel jobs
+# (max) to schedule on that machine.
+{
+    "remote_worker_records": [
+        {"username": "scott", "machine": "machine_one", "weight": 24, "count": 5},
+        {"username": "scott", "machine": "machine_two", "weight": 10, "count": 2},
+        {"username": "scott", "machine": "machine_three", "weight": 14, "count": 1},
+        {"username": "scott", "machine": "machine_four", "weight": 9, "count": 2},
+        {"username": "scott", "machine": "machine_five", "weight": 9, "count": 2},
+    ]
+}
index ef74f93387ac63731f733515cb5487996a252bb4..ec17d9fd8c879b6353d8945c29068490065f7f63 100644 (file)
@@ -4,6 +4,7 @@
 The MIT License (MIT)
 
 Copyright (c) 2020 LuizaLabs
+
 Additions/Modifications Copyright (c) 2022 Scott Gasch
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
index ed76c9e2407f72c4ad4dffd9666a945f7df7b444..c47d38c0aab88da0835cb6919434532c5288ad08 100644 (file)
@@ -391,44 +391,54 @@ def n_timeunits_from_base(
     >>> base = string_to_datetime("2021/09/10 11:24:51AM-0700")[0]
 
     The next (1) Monday from the base datetime:
+
     >>> n_timeunits_from_base(+1, TimeUnit.MONDAYS, base)
     datetime.datetime(2021, 9, 13, 11, 24, 51, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=61200)))
 
     Ten (10) years after the base datetime:
+
     >>> n_timeunits_from_base(10, TimeUnit.YEARS, base)
     datetime.datetime(2031, 9, 10, 11, 24, 51, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=61200)))
 
     Fifty (50) working days (M..F, not counting holidays) after base datetime:
+
     >>> n_timeunits_from_base(50, TimeUnit.WORKDAYS, base)
     datetime.datetime(2021, 11, 23, 11, 24, 51, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=61200)))
 
     Fifty (50) days (including weekends and holidays) after base datetime:
+
     >>> n_timeunits_from_base(50, TimeUnit.DAYS, base)
     datetime.datetime(2021, 10, 30, 11, 24, 51, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=61200)))
 
     Fifty (50) months before (note negative count) base datetime:
+
     >>> n_timeunits_from_base(-50, TimeUnit.MONTHS, base)
     datetime.datetime(2017, 7, 10, 11, 24, 51, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=61200)))
 
     Fifty (50) hours after base datetime:
+
     >>> n_timeunits_from_base(50, TimeUnit.HOURS, base)
     datetime.datetime(2021, 9, 12, 13, 24, 51, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=61200)))
 
     Fifty (50) minutes before base datetime:
+
     >>> n_timeunits_from_base(-50, TimeUnit.MINUTES, base)
     datetime.datetime(2021, 9, 10, 10, 34, 51, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=61200)))
 
     Fifty (50) seconds from base datetime:
+
     >>> n_timeunits_from_base(50, TimeUnit.SECONDS, base)
     datetime.datetime(2021, 9, 10, 11, 25, 41, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=61200)))
 
     Next month corner case -- it will try to make Feb 31, 2022 then count
     backwards.
+
     >>> base = string_to_datetime("2022/01/31 11:24:51AM-0700")[0]
     >>> n_timeunits_from_base(1, TimeUnit.MONTHS, base)
     datetime.datetime(2022, 2, 28, 11, 24, 51, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=61200)))
 
     Last month with the same corner case
+
     >>> base = string_to_datetime("2022/03/31 11:24:51AM-0700")[0]
     >>> n_timeunits_from_base(-1, TimeUnit.MONTHS, base)
     datetime.datetime(2022, 2, 28, 11, 24, 51, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=61200)))
index 575e64e7ff8fbd151a936201385c05fc5b61555a..69ab83707211a76ee2a9b32a54af20a5a61d8443 100644 (file)
@@ -4,6 +4,7 @@
 """The MIT License (MIT)
 
 Copyright (c) 2016-2020 Davide Zanotti
+
 Modifications Copyright (c) 2021-2022 Scott Gasch
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1680,7 +1681,7 @@ def sprintf(*args, **kwargs) -> str:
 
     Returns:
         An interpolated string capturing print output, like man(3)
-        :code:sprintf.
+        `sprintf`.
     """
     ret = ""
 
@@ -2033,7 +2034,11 @@ def ngrams_presplit(words: Sequence[str], n: int):
 
 
 def bigrams(txt: str):
-    """Generates the bigrams (n=2) of the given string."""
+    """Generates the bigrams (n=2) of the given string.
+
+    >>> [x for x in bigrams('this is a test')]
+    ['this is', 'is a', 'a test']
+    """
     return ngrams(txt, 2)